$ouName="Funky Dudes"
$ouPath = "ou=$ouName,dc=intranet,dc=baam,dc=com"
$plaintextPassword='WHATPASSWORD?'
$users=Get-ADUser -Filter * -SearchBase $ouPath | Select-object Name,UserPrincipalName,DistinguishedName
foreach ($user in $users){
write-host "Resetting '$($user.Name)' password to '$plaintextPassword'";
pause;
try{
Set-ADAccountPassword -Identity $user.DistinguishedName -Reset -NewPassword (ConvertTo-SecureString -AsPlainText $plaintextPassword -Force);
write-host "'$($user.DistinguishedName)' password has been reset successfully";
}
catch{
write-host 'failed.'
}
}
Categories: