I'm writing a script to show the missing/new items between two content branches. For the target of the comparison, I build an item path and then call
Get-Item on that path to see if there is an equivalent item. The problem is that Get-Item throws an exception if no item is found - I would just like to handle a case of a 'null' item in my script.
#$source is the root path of the source branch $localPath = $sourceItem.Paths.FullPath.SubString($source.Length) $targetPath = "master:" + $target + "/" + $localPath $targetItem = Get-Item $targetPath
The script works in that $targetItem is null if no item is found using $targetPath but I would like to suppress the error message in the script.