I often have the following situation in my PowerShell code: I have a function or property that returns a collection of objects, or $null. If you push the results in
$null
Another possibility:
$objects | Foreach-Object -Begin{If($_ -eq $null){continue}} -Process {do your stuff here}
More info in about_Continue