jojo
jojo

Reputation: 1

Powershell - Force reset password for a specific OU in AD

I'm Beginner in PowerShell scripting and I want write a script or run a PowerShell command on server to reset password to an OU in my AD.

Ex. : All users in

OU "Test"
Domain : MyServer.MyDomain.com

Perhaps someone to help me. Thanks in advance ;)

Upvotes: 0

Views: 2426

Answers (1)

DanL
DanL

Reputation: 2024

Try this:

Get-ADUser -Filter * -SearchBase "OU=Test,DC=myserver,DC=mydomain,DC=com" | % { Set-ADUser $_ -ChangePasswordAtLogon $true }

Though this will fail for accounts which have the password never expires attribute set

If you wish to change all accounts to have passwords that expire then run the following:

Get-ADUser -Filter * -SearchBase "OU=Test,DC=myserver,DC=mydomain,DC=com" | % { Set-ADUser $_ -PasswordNeverExpires $false }

Upvotes: 1

Related Questions