mirror of
https://github.com/EvotecIT/GPOZaurr.git
synced 2026-07-26 11:49:17 +00:00
Changed pipeline foreach into foreach for better/safer results
This commit is contained in:
@@ -128,30 +128,31 @@
|
||||
}
|
||||
|
||||
Write-Verbose -Message "Get-GPOZaurrRedirect - Searching domain $Domain with filter $($Splat['Filter'])"
|
||||
Get-ADObject @Splat -Properties DisplayName, Name, Created, Modified, ntSecurityDescriptor, gPCFileSysPath, gPCFunctionalityVersion, gPCWQLFilter, gPCMachineExtensionNames, Description, CanonicalName, DistinguishedName | ForEach-Object -Process {
|
||||
$DomainCN = ConvertFrom-DistinguishedName -DistinguishedName $_.DistinguishedName -ToDomainCN
|
||||
$GUID = $_.Name -replace '{' -replace '}'
|
||||
$Objects = Get-ADObject @Splat -Properties DisplayName, Name, Created, Modified, ntSecurityDescriptor, gPCFileSysPath, gPCFunctionalityVersion, gPCWQLFilter, gPCMachineExtensionNames, Description, CanonicalName, DistinguishedName
|
||||
foreach ($Object in $Objects) {
|
||||
$DomainCN = ConvertFrom-DistinguishedName -DistinguishedName $Object.DistinguishedName -ToDomainCN
|
||||
$GUID = $Object.Name -replace '{' -replace '}'
|
||||
if (($GUID).Length -ne 36) {
|
||||
Write-Warning "Get-GPOZaurrRedirect - GPO GUID ($($($GUID.Replace("`n",' ')))) is incorrect. Skipping $($_.DisplayName) / Domain: $($DomainCN)"
|
||||
Write-Warning "Get-GPOZaurrRedirect - GPO GUID ($($($GUID.Replace("`n",' ')))) is incorrect. Skipping $($Object.DisplayName) / Domain: $($DomainCN)"
|
||||
} else {
|
||||
$Path = $_.gPCFileSysPath
|
||||
$Path = $Object.gPCFileSysPath
|
||||
$ExpectedPath = "\\$($DomainCN)\SYSVOL\$($DomainCN)\Policies\{$($GUID)}"
|
||||
$Compare = if ($Path -eq $ExpectedPath) { $true } else { $false }
|
||||
[PSCustomObject]@{
|
||||
'DisplayName' = $_.DisplayName
|
||||
'DisplayName' = $Object.DisplayName
|
||||
'DomainName' = $DomainCN
|
||||
'Description' = $_.Description
|
||||
'Description' = $Object.Description
|
||||
'IsCorrect' = $Compare
|
||||
'GUID' = $GUID
|
||||
'Path' = $Path
|
||||
'ExpectedPath' = $ExpectedPath
|
||||
#$Output['FunctionalityVersion'] = $_.gPCFunctionalityVersion
|
||||
'Created' = $_.Created
|
||||
'Modified' = $_.Modified
|
||||
'Owner' = $_.ntSecurityDescriptor.Owner
|
||||
'GPOCanonicalName' = $_.CanonicalName
|
||||
'GPODomainDistinguishedName' = ConvertFrom-DistinguishedName -DistinguishedName $_.DistinguishedName -ToDC
|
||||
'GPODistinguishedName' = $_.DistinguishedName
|
||||
#$Output['FunctionalityVersion'] = $Object.gPCFunctionalityVersion
|
||||
'Created' = $Object.Created
|
||||
'Modified' = $Object.Modified
|
||||
'Owner' = $Object.ntSecurityDescriptor.Owner
|
||||
'GPOCanonicalName' = $Object.CanonicalName
|
||||
'GPODomainDistinguishedName' = ConvertFrom-DistinguishedName -DistinguishedName $Object.DistinguishedName -ToDC
|
||||
'GPODistinguishedName' = $Object.DistinguishedName
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user