James
 Basic Member Posts:374

 |
| 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 Levy PowerShell MVP, Admin
 Veteran Member Posts:1362

 |
|
James
 Basic Member Posts:374

 |
| 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 |
|
|
|
|
James
 Basic Member Posts:374

 |
| 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 Levy PowerShell MVP, Admin
 Veteran Member Posts:1362

 |
| 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 |
|
|
James
 Basic Member Posts:374

 |
| 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 Levy PowerShell MVP, Admin
 Veteran Member Posts:1362

 |
|
James
 Basic Member Posts:374

 |
| 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 Levy PowerShell MVP, Admin
 Veteran Member Posts:1362

 |
|
James
 Basic Member Posts:374

 |
| 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 |
|
|
|
|
James
 Basic Member Posts:374

 |
| 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 |
|
|
|
|
James
 Basic Member Posts:374

 |
| 02 Dec 2009 01:23 AM |
|
Well thats worked fine. Many Thanks for all your help James |
|
|
|
|