I have some code and a csv file where I'm trying to bulk update users in AD.
$cred = Get-Credential $csv = '.\UpdateUsers - Copy.csv' $userlist = Import-Csv $csv $userlist | foreach { Set-ADUser -Identity $_.SamAccountName -EA stop -City $_.City -Company $_.Company -Country $_.Country -Department $_.Department -Description $_.Description -DisplayName $_.DisplayName -EmailAddress $_.EmailAddress -EmployeeID $_.EmployeeID -EmployeeNumber $_.EmployeeNumber -Fax $_.Fax -GivenName $_.GivenName -MobilePhone $_.MobilePhone -Office $_.Office -OfficePhone $_.OfficePhone -POBox $_.POBox -PostalCode $_.PostalCode -SamAccountName $_.SamAccountName -State $_.State -StreetAddress $_.StreetAddress -Surname $_.Surname -Title $_.Title -UserPrincipalName $_.UserPrincipalName -Manager $_.manager -Credential $cred }The command succeeds on most of the users in the csv file. It seems to fail, however, when it comes across an attribute that is null. For example, there are users in the csv file that have no value for the OfficePhone attribute. How would I handle the script allowing null values for any of these properties?