header1   header
header
header Register : : Login header
header
connector   connector
menuleft menuright
submenu   submenu
left
Setting Password At Next Logon
Last Post 02 Dec 2009 01:23 AM by James. 11 Replies.
Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
JamesUser is Offline
Basic Member
Basic Member
Posts:374
Avatar

--
01 Dec 2009 03:19 AM
    Hello,

    I have the following:

    <br><br>Import-Csv -Path "C:\TestEMail.csv"<br>ForEach-Object {<br><br>$user = Get-User -Identity $.Alias<br><br>$user.put("pwdLastset",0)<br>$user.setinfo()<br>}<br><br>


    Basically whats happening is I am getting errors with the above and its not setting the password at next logon.

    What am I doing wrong?

    Many Thanks

    James
    Shay LevyUser is Offline
    PowerShell MVP, Admin
    Veteran Member
    Veteran Member
    Posts:1362
    Avatar

    --
    01 Dec 2009 05:22 AM
    Get-User user1 | Set-User -ResetPasswordOnNextLogon $true

    Shay Levy
    Windows PowerShell MVP
    http://PowerShay.com
    PowerShell Community Toolbar
    Twitter: @ShayLevy
    JamesUser is Offline
    Basic Member
    Basic Member
    Posts:374
    Avatar

    --
    01 Dec 2009 05:58 AM
    Hello,

    Many Thanks for your reply.

    I have tried the following:

    #ImportCSV
    Import-Csv -Path "C:\test.csv" |
    ForEach-Object {
    #Get the user from the CSV
    Get-User -Identity $_.Alias
    #Set the password to change at next logon
    Set-User -ResetPasswordOnNextLogon $true
    #Set-User -PasswordNeverExpires $false
    }

    I am getting a warning which says its completed successfuly but no settings have been changed. However I am also getting prompted for the Identity when I run it. Do you know why?

    I am logged on as a domain admin and everything else seems to work fine.

    Also I am trying to turn off the Password Never Expires as I have noticed this also needs to be unchecked.

    Many Thanks for your help

    James
    JamesUser is Offline
    Basic Member
    Basic Member
    Posts:374
    Avatar

    --
    01 Dec 2009 05:59 AM
    Oh one more thing.

    I am doing this on the Exchange box.

    Do I need to do this on the DC's?

    Many Thanks

    James
    Shay LevyUser is Offline
    PowerShell MVP, Admin
    Veteran Member
    Veteran Member
    Posts:1362
    Avatar

    --
    01 Dec 2009 06:02 AM
    You are missing the pipe symbol between get and set cmdlets, you don't need to run this on a dc:

    Import-Csv C:\test.csv | ForEach-Object { Get-User -Identity $_.Alias | Set-User -ResetPasswordOnNextLogon $true }



    Shay Levy
    Windows PowerShell MVP
    http://PowerShay.com
    PowerShell Community Toolbar
    Twitter: @ShayLevy
    JamesUser is Offline
    Basic Member
    Basic Member
    Posts:374
    Avatar

    --
    01 Dec 2009 06:49 AM
    Hello,

    I have used your code and still its saying it completed however no settings have been modified.

    Is there anything else I need to do or change?

    Many Thanks

    James
    Shay LevyUser is Offline
    PowerShell MVP, Admin
    Veteran Member
    Veteran Member
    Posts:1362
    Avatar

    --
    01 Dec 2009 06:54 AM
    Have you checked all DC's?

    You can try to set a DC in -DomainController param of set-user.

    Shay Levy
    Windows PowerShell MVP
    http://PowerShay.com
    PowerShell Community Toolbar
    Twitter: @ShayLevy
    JamesUser is Offline
    Basic Member
    Basic Member
    Posts:374
    Avatar

    --
    02 Dec 2009 12:33 AM
    Hello,

    Many Thanks for your responses.

    I have still got the same warning message with the following code:

    #ImportCSV
    #Get the user from the CSV file
    #Set the password to change at next logon
    #Move on
    Import-Csv "C:\test.csv" | ForEach-Object { Get-User -Identity $_.Alias | Set-User -DomainController "dcnamehere" -ResetPasswordOnNextLogon $true }


    Is there anything else I can try?

    Many Thanks

    James
    Shay LevyUser is Offline
    PowerShell MVP, Admin
    Veteran Member
    Veteran Member
    Posts:1362
    Avatar

    --
    02 Dec 2009 01:05 AM
    What's the error?

    Shay Levy
    Windows PowerShell MVP
    http://PowerShay.com
    PowerShell Community Toolbar
    Twitter: @ShayLevy
    JamesUser is Offline
    Basic Member
    Basic Member
    Posts:374
    Avatar

    --
    02 Dec 2009 01:16 AM
    Shay,

    Its still giving the warning of the command completed sucessfully but nothing has been modified.

    Many Thanks again

    James
    JamesUser is Offline
    Basic Member
    Basic Member
    Posts:374
    Avatar

    --
    02 Dec 2009 01:19 AM
    Hello,

    I have just run it now and its worked fine for some bizarre reason I will give it the rest of the CSV and see how it copes with it.

    Many Thanks

    James
    JamesUser is Offline
    Basic Member
    Basic Member
    Posts:374
    Avatar

    --
    02 Dec 2009 01:23 AM
    Well thats worked fine.

    Many Thanks for all your help

    James
    You are not authorized to post a reply.


    Active Forums 4.3
    right
    footer   footer
    footer Sponsored by Quest Software • SAPIEN Technologies • Compellent • Microsoft Windows Server 2008 R2 footer
    footer   footer