Hi.
I’m making changes to AD with information from a CSV file, sometimes fields are empty on some users, could be telephone number, and that translate to that they should be empty in AD as well. How would i do that?
Right now i get an error for each empty field…
$users = Import-CSV -Delimiter ";" -Path c:\pathtocsv.csv
ForEach($User in $Users){
$ADUser = Get-ADUser -Identity $($User.SamAccountName) -Properties *
if ($ADUser){
Set-ADUser -Identity $ADUser `
-Country $User.Country `
-Department $User.Department `
-OfficePhone $User.OfficePhone `
-StreetAddress $User.Address `
-City $User.City `
-State $User.State `
-PostalCode $User.PostalCode `
-Mobile $User.MobilePhone `
-Office $User.Office `
}else{
Write-Warning ("Failed to update " + $($User.SamAccountName))
}
}