Thursday, June 14, 2012

import-csv ---> foreach ---> get-aduser --> set-aduser




Pay attention to how the varriable has been used inside -filter parameter which is inside foreach. review article link below to understand better http://www.sapien.com/forums/scriptinganswers/forum_posts.asp?TID=4074


C:\>Import-Csv .\import.csv| foreach{
Get-ADUser -filter "EmailAddress -like '$($_.email)'" | Set-ADUser -OfficePhone $_.phone
}

the whole thing above can be on the same line

sample import.csv file
email, phone
xyz@abc.com, 818-549-12380 x4755


No comments: