From fe080aece9f4697413be5c3d13f9a83392e06b7a Mon Sep 17 00:00:00 2001 From: Przemyslaw Klys Date: Fri, 17 Jul 2020 10:04:36 +0200 Subject: [PATCH] Small fix for a crash --- Public/Invoke-GPOZaurr.ps1 | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Public/Invoke-GPOZaurr.ps1 b/Public/Invoke-GPOZaurr.ps1 index 58ada4e..c96f48f 100644 --- a/Public/Invoke-GPOZaurr.ps1 +++ b/Public/Invoke-GPOZaurr.ps1 @@ -57,10 +57,15 @@ } #> - $GPOFiles = Get-ChildItem -LiteralPath $GPOPath -Recurse -File + $GPOFiles = Get-ChildItem -LiteralPath $GPOPath -Recurse -File -Filter *.xml [Array] $GPOs = foreach ($File in $GPOFiles) { if ($File.Name -ne 'GPOList.xml') { - [xml] $GPORead = Get-Content -LiteralPath $File.FullName + try { + [xml] $GPORead = Get-Content -LiteralPath $File.FullName + } catch { + Write-Warning "Invoke-GPOZaurr - Couldn't process $($File.FullName) error: $($_.Exception.message)" + continue + } [PSCustomObject] @{ DisplayName = $GPORead.GPO.Name DomainName = $GPORead.GPO.Identifier.Domain.'#text'