From 823f2095d4d25e25d59e3606c34245c970f18247 Mon Sep 17 00:00:00 2001 From: Przemyslaw Klys Date: Mon, 23 Nov 2020 18:51:46 +0100 Subject: [PATCH] Update --- Public/Invoke-GPOZaurr.ps1 | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Public/Invoke-GPOZaurr.ps1 b/Public/Invoke-GPOZaurr.ps1 index 32b9c5b..b1dfe01 100644 --- a/Public/Invoke-GPOZaurr.ps1 +++ b/Public/Invoke-GPOZaurr.ps1 @@ -66,7 +66,14 @@ } $TimeLogGPOList = Start-TimeLog Write-Color -Text '[i]', '[Start] ', $($Script:GPOConfiguration[$T]['Name']) -Color Yellow, DarkGray, Yellow - $Script:Reporting[$T]['Data'] = Invoke-Command -ScriptBlock $Script:GPOConfiguration[$T]['Execute'] -WarningVariable CommandWarnings -ErrorVariable CommandErrors -ArgumentList $Forest, $ExcludeDomains, $IncludeDomains + $OutputCommand = Invoke-Command -ScriptBlock $Script:GPOConfiguration[$T]['Execute'] -WarningVariable CommandWarnings -ErrorVariable CommandErrors -ArgumentList $Forest, $ExcludeDomains, $IncludeDomains + if ($OutputCommand -is [System.Collections.IDictionary]) { + # in some cases the return will be wrapped in Hashtable/orderedDictionary and we need to handle this without an array + $Script:Reporting[$T]['Data'] = $OutputCommand + } else { + # since sometimes it can be 0 or 1 objects being returned we force it being an array + $Script:Reporting[$T]['Data'] = [Array] $OutputCommand + } Invoke-Command -ScriptBlock $Script:GPOConfiguration[$T]['Processing'] $Script:Reporting[$T]['WarningsAndErrors'] = @( foreach ($War in $CommandWarnings) {