From 971f5a18e38c286287d9072ed68cb0bf18869eae Mon Sep 17 00:00:00 2001 From: Przemyslaw Klys Date: Fri, 15 May 2020 11:20:03 +0200 Subject: [PATCH] Update GPOZaurrAD --- Examples/Example-13-ListingOwners02.ps1 | 4 ++-- GPOZaurr.psd1 | 2 +- Public/Get-GPOZaurrAD.ps1 | 31 +------------------------ Public/Get-GPOZaurrOwner.ps1 | 3 ++- 4 files changed, 6 insertions(+), 34 deletions(-) diff --git a/Examples/Example-13-ListingOwners02.ps1 b/Examples/Example-13-ListingOwners02.ps1 index de2aec8..6a941f5 100644 --- a/Examples/Example-13-ListingOwners02.ps1 +++ b/Examples/Example-13-ListingOwners02.ps1 @@ -1,7 +1,7 @@ Import-Module "$PSScriptRoot\..\GPoZaurr.psd1" -Force -#$T = Get-GPOZaurrOwner -Verbose -IncludeSysvol -Forest 'test.evotec.pl' -#$T | Format-Table * +$T = Get-GPOZaurrOwner -Verbose -IncludeSysvol +$T | Format-Table * #$T | Out-HtmlView -ScrollX $T = Get-GPOZaurrOwner -Verbose -IncludeSysvol -GPOName 'Default Domain Policy' diff --git a/GPOZaurr.psd1 b/GPOZaurr.psd1 index 5483081..4e0be03 100644 --- a/GPOZaurr.psd1 +++ b/GPOZaurr.psd1 @@ -21,7 +21,7 @@ ModuleName = 'PSSharedGoods' Guid = 'ee272aa8-baaa-4edf-9f45-b6d6f7d844fe' }, @{ - ModuleVersion = '0.0.55' + ModuleVersion = '0.0.56' ModuleName = 'ADEssentials' Guid = '9fc9fd61-7f11-4f4b-a527-084086f1905f' }, 'ActiveDirectory', 'GroupPolicy', 'CimCmdlets', 'Microsoft.PowerShell.Management', 'Microsoft.PowerShell.Utility' diff --git a/Public/Get-GPOZaurrAD.ps1 b/Public/Get-GPOZaurrAD.ps1 index ba59d4d..e9f4dec 100644 --- a/Public/Get-GPOZaurrAD.ps1 +++ b/Public/Get-GPOZaurrAD.ps1 @@ -48,22 +48,9 @@ Server = $ForestInformation['QueryServers'][$Domain]['HostName'][0] } } - Get-ADObject @Splat -Properties DisplayName, Name, Created, Modified, gPCFileSysPath, gPCFunctionalityVersion, gPCWQLFilter, gPCMachineExtensionNames, Description, CanonicalName, DistinguishedName | ForEach-Object -Process { #, Deleted -IncludeDeletedObjects - #if ($_) { + Get-ADObject @Splat -Properties DisplayName, Name, Created, Modified, gPCFileSysPath, gPCFunctionalityVersion, gPCWQLFilter, gPCMachineExtensionNames, Description, CanonicalName, DistinguishedName | ForEach-Object -Process { $DomainCN = ConvertFrom-DistinguishedName -DistinguishedName $_.DistinguishedName -ToDomainCN $Output = [ordered]@{ } - <# - $Search = -join ($DomainCN, $Output['Guid']) - if ($GPOCache -and -not $Limited) { - $Output['DisplayName'] = $GPOCache[$Search].DisplayName - $Output['DomainName'] = $GPOCache[$Search].DomainName - $Output['Owner'] = $GPOCache[$Search].Owner - $Output['GpoStatus'] = $GPOCache[$Search].GpoStatus - $Output['Description'] = $GPOCache[$Search].Description - $Output['CreationTime'] = $GPOCache[$Search].CreationTime - $Output['ModificationTime'] = $GPOCache[$Search].ModificationTime - } - #> $Output['DisplayName'] = $_.DisplayName $Output['DomainName'] = $DomainCN $Output['Description'] = $_.Description @@ -76,22 +63,6 @@ $Output['GPODomainDistinguishedName'] = ConvertFrom-DistinguishedName -DistinguishedName $_.DistinguishedName -ToDC $Output['GPODistinguishedName'] = $_.DistinguishedName [PSCustomObject] $Output - - <# - CanonicalName : ad.evotec.xyz/System/Policies/{31B2F340-016D-11D2-945F-00C04FB984F9} - Created : 20.05.2018 09:55:29 - Description : - DisplayName : Default Domain Policy - DistinguishedName : CN={31B2F340-016D-11D2-945F-00C04FB984F9},CN=Policies,CN=System,DC=ad,DC=evotec,DC=xyz - gPCFileSysPath : \\ad.evotec.xyz\sysvol\ad.evotec.xyz\Policies\{31B2F340-016D-11D2-945F-00C04FB984F9} - gPCFunctionalityVersion : 2 - gPCMachineExtensionNames : [{35378EAC-683F-11D2-A89A-00C04FBBCFA2}{53D6AB1B-2488-11D1-A28C-00C04FB94F17}][{827D319E-6EAC-11D2-A4EA-00C04F79F83A}{803E14A0-B4FB-11D0-A0D0-00A0C90F574B}][{B1BE8D72-6EAC-11D2-A4EA-00C04F79F83A}{53D6AB1B-2488-11D1-A28C-00C04FB94F17}] - Modified : 26.04.2020 18:53:56 - Name : {31B2F340-016D-11D2-945F-00C04FB984F9} - ObjectClass : groupPolicyContainer - ObjectGUID : 679a6dd9-30fb-438c-a35f-e5fe8167703e - #> - #} } } } diff --git a/Public/Get-GPOZaurrOwner.ps1 b/Public/Get-GPOZaurrOwner.ps1 index 8af695d..4aaa01d 100644 --- a/Public/Get-GPOZaurrOwner.ps1 +++ b/Public/Get-GPOZaurrOwner.ps1 @@ -30,7 +30,8 @@ } elseif ($GPOGuid) { $getGPOZaurrADSplat['GPOGUID'] = $GPOGuid } - Get-GPOZaurrAD @getGPOZaurrADSplat | ForEach-Object -Process { + $Objects = Get-GPOZaurrAD @getGPOZaurrADSplat + foreach ($_ in $Objects) { Write-Verbose "Get-GPOZaurrOwner - Processing GPO: $($_.DisplayName) from domain: $($_.DomainName)" $ACL = Get-ADACLOwner -ADObject $_.GPODistinguishedName -Resolve -ADAdministrativeGroups $ADAdministrativeGroups $Object = [ordered] @{