Last Updated: February 25, 2016
·
985
· operationnos

Attribute editing en mass- Active Directory

If you have a new attribute being added to Active Directory or need to make a mass change to an existing attribute, this can assist. It's currently set to verify using "employeeID" and perform updates to the "title" attribute. These can be changed to any default or custom attribute. The only add-on for Powershell that you'll need is Quest Active Roles Management Shell.

$outfile = @()
$outfile2 = @()
$outfile3 = @()
$ou = "domainFQDN.local/toplevelou"
$Users = import-csv "C:\csv\Userlist.csv"

Foreach($user in $Users){
    $u = get-qaduser -ou $ou -LDAPFILTER "(&(employeeID=$($User.employeeID)))"
        If (($u | Measure-Object).count -eq "1"){
            $u | set-qaduser -objectattributes @{title=$($user.title)}  
            $outfile3 += "$($user.Givenname),$($user.SN),$($user.employeeID), $($user.title)"     
        }
        Else{
            If (($u | Measure-Object).count -gt "1"){
                $outfile += "$($user.Givenname),$($user.SN),$($user.employeeID)"
            }
            Else{
                $outfile2 += "$($user.Givenname),$($user.SN),$($user.employeeID)"
            }

        }
} 
$outfile | out-file c:\duplicate_in_AD.txt
$outfile2 | out-file c:\not_in_AD.txt
$outfile3 | out-file c:\AD_changes.txt