Small fix for a crash

This commit is contained in:
Przemyslaw Klys
2020-07-17 10:04:36 +02:00
parent 95b814f2f9
commit fe080aece9
+7 -2
View File
@@ -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'