A bit longer than one line, but it does have error checking:
EDIT: Moved the $n = $_.Name inside the ForEach-Object block.
Get-ADComputer COMPUTER1 -Properties Name, extensionattribute1 |
ForEach-Object{
$n = $_.Name # needed to report computer name in Catch block
$u = Get-ADUser -Filter {Name -eq $_.extensionattribute1} -Properties physicalDeliveryOfficeName
if ($u){
Try{
$p = $u.physicalDeliveryOfficeName
Set-ADComputer $_ -Replace @{extensionattribute2 = $p} -ErrorAction Stop
}
Catch{
Write-Host "Failed to update computer object '$n'"
}
}
else{
Write-Host "Failed to find user '$($_.extensionattribute1)"
}
}