From 067c7581fdbaca482525063ad73ef0d134598cff Mon Sep 17 00:00:00 2001 From: James Forshaw Date: Thu, 16 Dec 2021 20:59:42 +0000 Subject: [PATCH] Don't write out null servers. --- NtObjectManager/RpcFunctions.ps1 | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) 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 {