Reset Active Directory multiple users password in OU using powershell:
# Specify the OU.
$OU = [ADSI]"LDAP://ou=West,dc=MyDomain,dc=local"
# Enumerate all objects in the OU.
$arrChildren = $OU.Get_Children()
ForEach ($User In $arrChildren)
{
# Only consider user objects.
If ($User.Class -eq "user")
{
# Set password.
$User.Invoke("SetPassword", "123-zxc")
# Expire the password.
$User.pwdLastSet = 0
$User.SetInfo()
}
}
# Specify the OU.
$OU = [ADSI]"LDAP://ou=West,dc=MyDomain,dc=local"
# Enumerate all objects in the OU.
$arrChildren = $OU.Get_Children()
ForEach ($User In $arrChildren)
{
# Only consider user objects.
If ($User.Class -eq "user")
{
# Set password.
$User.Invoke("SetPassword", "123-zxc")
# Expire the password.
$User.pwdLastSet = 0
$User.SetInfo()
}
}
No comments:
Post a Comment