-errorVariable causes an error message (if the cmdlet fails) to be stored in the specified variable. -errorVariable is a string, not a variable (-errorVariable err, not -errVariable $err). $error, the type of the indicated variable is System.Collections.ArrayList whose elements store System.Management.Automation.ErrorRecord objects. $item = get-item `
inexisting-item `
-errorVariable err `
-errorAction silentlyContinue
if ($err) {
write-host $err
}
else {
write-host "item $item found"
}