Objective: Updates a specific attribute for multiple users at once.
Script:
# Sample: Set the Department attribute for users in a specific OU
$OUPath = "OU=Sales,OU=Users,DC=contoso,DC=com"
$NewDepartment = "Sales"
Get-ADUser -Filter * -SearchBase $OUPath | ForEach-Object {
Set-ADUser -Identity $_ -Department $NewDepartment
}
Before executing any script, ensure that you understand its functionality, customize it based on your environment, and thoroughly test it in a non-production environment to avoid unintended consequences.
Here are five useful PowerShell scripts for managing Active Directory:
User Account Management Script:
Password Expiry Report:
Group Membership Report:
Disable Inactive Users:
Bulk User Attribute Update:
Before executing any script, ensure that you understand its functionality, customize it based on your environment, and thoroughly test it in a non-production environment to avoid unintended consequences.