diff --git a/NtObjectManager/RpcFunctions.ps1 b/NtObjectManager/RpcFunctions.ps1 index 31cdd0a2..f5c9d115 100644 --- a/NtObjectManager/RpcFunctions.ps1 +++ b/NtObjectManager/RpcFunctions.ps1 @@ -336,14 +336,17 @@ function Get-RpcServer { } } } - if ($AsText) { - foreach ($server in $servers) { - $text = $server.FormatAsText($RemoveComments) - Write-Output $text + + if ($null -ne $servers) { + if ($AsText) { + foreach ($server in $servers) { + $text = $server.FormatAsText($RemoveComments) + Write-Output $text + } + } + else { + Write-Output $servers } - } - else { - Write-Output $servers } } catch {