Skipping white space

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
}

If I’ve got this right you can use the instance method of the Set-ADUser cmdlet like this:

$props = ‘Revision’,‘Title’,‘Street’,‘StreetAddress’
Import-CSV C:\temp\Userdata.csv |
ForEach-Object{
if($u = Get-AdUser $.sAMAccountName -Properties $props){
$u.Title = $
.Title
$u.Revision = $.Revision
$u.Street = $
.Street
$u.StreetAddress = $_.StreetAddress
Set-AdUser -Instance $u
}else{
Write-Host ‘User not found’
}
}

untested!!
The credit for this goes to jrv and Richard Mueller … found in the Microsoft Technet Forum for Powershell