Good evening,
I am using csv file to feed into the script below that updates user attributes but there are some properties which doesn’t have values so it is erroring out.
I have used -erroraction silientlyContinue to get it working but what would be the best practice in this scenario and how can I add it to script below.
$data = Import-csv -path C:\temp\Userdata.csv Foreach ($user in $data) { Get-ADUser -Filter "samaccountname -eq '$($user.sAMAccountName)'" | Set-ADUser -Replace @{revision = "$($user.revision)"} -ErrorAction SilentlyContinue Get-ADUser -Filter "samaccountname -eq '$($user.sAMAccountName)'" | Set-ADUser -Replace @{title = "$($user.title)"} -ErrorAction SilentlyContinue Get-ADUser -Filter "samaccountname -eq '$($user.sAMAccountName)'" | Set-ADUser -Replace @{street = "$($user.street)"} -ErrorAction SilentlyContinue Get-ADUser -Filter "samaccountname -eq '$($user.sAMAccountName)'" | Set-ADUser -Replace @{streetAddress = "$($user.streetAddress)"} -ErrorAction SilentlyContinue }