Set password to never expire from CSV

by stu_mchugh at 2012-09-20 04:17:09

I’m trying to workout (and failing) how to set the “Password Never Expire” check box for a list of users in a CSV. I have tried with the follow code but don’t know to set the flag

$import=import-csv -Path "C:\stu\scripts\test.csv"
foreach($dataRecord in $import)
{
$sAMAccountName=$dataRecord.SamAccountName

$user=get-QADUser -identity $sAMAccountName

set-QADUser -identity $sAMAccountName
write-Output $user.DN

}


After the “Set-QADUser” and indentifty the user I don’t know how to set the password flag???
Any Ideas!?
by poshoholic at 2012-09-20 04:44:21
You need to use the -PasswordNeverExpires parameter, like this:
Set-QADUser -Identity $sAMAccountName -PasswordNeverExpires $true
by stu_mchugh at 2012-09-20 06:05:56
Nice one! thanks!
by RichardSiddaway at 2012-09-20 11:09:10
If you can’t use the quest cmdlets the other ways of doing it are given in this post
http://msmvps.com/blogs/richardsiddaway … xpire.aspx