Active Directory: mass change the option: The user cannot change the password

You want to increase the security level of your Active Directory environment, but historically the option: User cannot change password was enabled.

The script below allows you to modify this option in bulk on your entire directory or just one UO.

# Get user whith CannotChangePassword true / Edit SearchBase
$users = Get-ADUser -Filter * -Properties CannotChangePassword -SearchBase "OU=OUNAME,DC=domain,DC=lan" | where { $_.CannotChangePassword -eq "true" }

# Browse Users and change to false CannotChangePassword
foreach( $user in $users){
 Set-ADUser $user -CannotChangePassword $False
}
Romain Drouche

Romain Drouche

System Architect | MCSE: Core Infrastructure

An IT infrastructure expert with over 15 years of hands-on experience. Currently serving as a Systems and Network Project Manager and Information Systems Security (ISS) Lead, I leverage my expertise to ensure the reliability and security of technological environments.

GHinM▶