In this post we are going to look at a simple script to change AD attributes on a large scale with minimal effort.
Although bare in mind every Active Directory structure has it’s differences, parts of the script or the majority of it’s contents may not be applicable to your current situation.
However, personally I’ve created little scripts similar to the one highlighted in this post for clients and they have proved beneficial in saving time and keeping their AD uniform and presentable.
Most important is knowing that it’s almost a given that the script below will need to be changed by yourself to suit your needs.
What this script does –
It retrieves all the AD user accounts in a specific OU and puts them in a list. To which the script goes through each object in the list making sure the Username (SamAccountName), email, AD display name and UPN are as follows –
UPN – BobSmith@contoso.com
SAM – Smithb
Email – BobSmith@contoso.com
AD Object Name – JSY.BobSmith (How it appears in Active Directory – name attribute)
Test it on one user –
To test it on one AD Object you can change the first command to filter by a specified name rather than the wildcard (*) which retrieves everything in the OU.
You may have noticed it’s already in the script just as a comment –
Get-ADUser -SearchBase ‘OU=Staff,OU=Users,OU=Finance,DC=contoso,DC=com’ -filter ‘Name -eq “Test User“‘ -Properties *
Add more to the script or change it up completely –
Using the Set-ADuser technet page you have all the different parameters listed at your disposal to tailor the script to your AD environment or create your own from scratch.
Hope this was helpful!