Skip to content

Empty id results in dynamic drop down causes object reference error

Problem

If a drop down with dynamics bind search results contains empty/null values in the ID column, client web service will throw an error

drop down with empty id in result

Solution

Make sure you filter out empty results with the Where-Object cmdlet before using the Select-Object cmdlet

Example:

$computers | where-object { $_.ObjectGUID -ne $null } | select-object @{Name="Id";Expression={[guid]$_.ObjectGUID}}, @{Name="";Expression={ ... }}