jmateknik
asked on
Powershell-script: Modify of local(non-AD)-user accounts
I am looking for an [adsi]("WinNT://./$strUser , user") --> psbase.invoke("?","?") command for enabling 'Password never expires' and 'User cannot change password'.
I have succesfully build a script that changes passwords according to an CSV-file - see attached script, and now imagine adding two lines of code doing the job.
Help is greatly appreciated...
I have succesfully build a script that changes passwords according to an CSV-file - see attached script, and now imagine adding two lines of code doing the job.
Help is greatly appreciated...
{
$ImportUserListPath = "E:\Anders\JmaWebUserNamesPasswords.csv"
$users = Import-Csv $ImportUserListPath
Foreach ($user in $users)
{
$strUser = $User.username
$strPWD = $User.Password
$strUser
$LocalUser =[adsi]("WinNT://./$strUser, user")
$LocalUser.psbase.invoke("SetPassword", $strPWD)
# Password never expires: $LocalUser.psbase.invoke( ??? )
# User cannot change password: $LocalUser.psbase.invoke( ??? )
}
}
setPasswordFromCSV
http://www.computerperformance.co.uk/powershell/powershell_qad_user.htm
QAD can only be used for AD accounts, not local.
I haven't tried this myself, but both these entries are userflags so you should be able to set the value of the userflag for the account. A good list of the values (which you simply add together) is at http://www.motobit.com/help/usrmgr/cl16.htm
I haven't tried this myself, but both these entries are userflags so you should be able to set the value of the userflag for the account. A good list of the values (which you simply add together) is at http://www.motobit.com/help/usrmgr/cl16.htm
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I Humbly thanks for the joy that this script has spread - exellent! :)