Tuesday, July 8, 2014

Modify multiple Active Directory Accounts with PowerShell

Has you company recently moved to a new location? If so here is a script to modify the "StreetAddress" Active Directory attribute for multiple users at once.
Import-Module ActiveDirectory
 $users = $i = $null
 $users = Get-ADUser -filter * -property StreetAddress
 ForEach($user in $users)
      "modifying $($user.name)"
      Set-ADUser -Identity $user.distinguishedName -StreetAddress "1600 Pennsylvania Ave NW"

This could be used to modify any of the Active Directory attributes by simply editing the -property being queried.