In my other post I was helped out on using the command pwdlastset
I decided I would then try to build on that.
1. create a CSV file and import
2. take each value as it comes in and change it.
I came up with the following but something odd is happening:
its asking for an identity. (I got the idea from another script that I had which creates accounts, see below) any idea what I is wrong in my thinking here?
--------------------------
PS C:\Windows\system32> # Import from CSV
Import-csv c:\scripts\Book1.csv | Foreach-Object { Set-ADUser -Replace @{pwdLastSet=0}}
cmdlet Set-ADUser at command pipeline position 1
Supply values for the following parameters:
Identity:
--------------------------
I got the idea from another script that I had which creates user accounts. it was similar type of item using the new_ADUser instead of the set-ADuser but the important thing I wanted was to create a for loop but was not sure how in power shell and this seemed to use that.
-----------------------------
# Import from CSV
Import-csv c:\scripts\PSBulkAccountCreation.csv | ForEach-Object {
New-ADUser -Path "OU=users,DC=somename" -Name $_.Name -SamAccountName $_.SamAccountName -Description $_.Description -emailaddress $_.emailaddress -AccountPassword
(ConvertTo-Securestring -AsplainText $_.AccountPassword -Force) -Enable $true -ChangePasswordatlogon 0 -PasswordNeverExpires:$true
}
}
-----------------------------