Hello,
Actually, using the try...catch block is the correct answer when dealing with empty values, however the statement in the try statement is incorrect. The correct statement will be:
$desc = $subordinate.Get("description")
Also, you get the subordinate's name two times (when generating the report part and when storing a record to the Execution Log). A better option would be to store the subordinate's name in a certain variable and use that variable. The following script block will do the job you need:
foreach ($subordinateDN in $subordinateDNs)
{
$subordinate = $Context.BindToObjectByDN($subordinateDN)
try
{
$desc = $subordinate.Get("description")
}
catch
{
$desc = "No Description"
}
$subordinateName = $subordinate.Get("name")
$htmlReportMiddlePart += "Name: <b>" + $subordinateName + "</b> -> " + $desc + "<br>"
# Output to GUI execution status report
$Context.LogMessage($subordinateName, "Information")
}