Does this produce the results you wanted?
$RDSADGROUP = "Remote_Desktop_Services"
(Get-ADGroupMember -Identity $ADGROUP).name |
Foreach-Object{
Try {
Invoke-Command -ComputerName $_ -scriptblock {
$result = gwmi -namespace "Root/CIMV2/TerminalServices" Win32_TerminalServiceSetting
[PSCustomObject]@{
SpecifiedLSList = $result.GetSpecifiedLicenseServerList().SpecifiedLSList
LicensingType = $result.LicensingType
LicensingName = $result.LicensingName
ServerName = $result.ServerName
}
} -ErrorAction STOP # SilentlyContinue won't cause the "Catch" block to execute if Invoke-Command fails
}
Catch{ # This will result in two lines of text being present in the midst of the results of the successful Invoke-Command outputs
# which will probably mess up the way they're displayed
Write-Output "nError Message: " $.Exception.Message
Write-Output "`nError Item Name: "$.Exception.ItemName
}
}