Change AD-User property’s using PowerShell

# =======================================================
#
# Microsoft PowerShell Source File
#
# NAME: Update Active Directory Users 
#
# AUTHOR: JWN
# DATE  : 11/01/2011
#
# COMMENT: This sample script performs an update of AD users
# Using the powergui AD module http://www.powergui.org/index.jspa
# ========================================================
$users = $null
$dummy = $null
$users = Get-QADUser -searchRoot "OU=…..,OU=DomainAccounts,DC=contoso,DC=nl"
$csv = Import-Csv c:\scripts\nawgegevens.csv -delimiter ‘,’
# Loop through AD user
    ForEach($user in $users) 
    { 
        # Loop through Imported users from csv
        ForEach($persoon in $csv)
        {
        # If there is a match between LastName
        if($user.LastName -eq $persoon.Naam) 
            {
            #set dummy var for adress
            $dummy = $persoon.adres + " " + $persoon.huisnr
            #Update User
            Set-QADUser -Identity $user.DN -City $persoon.woonplaats -PostalCode $persoon.postcode -HomePhone $persoon.telefoon -StreetAddress $dummy -StateOrProvince " "
            $dummy = $null   
            }
        }
    }

This entry was posted in PowerShell, Windows Server 2008, Windows7 and tagged , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *