diff --git a/Examples/Example-11-ReplaceGPOOwnerAutomated.ps1 b/Examples/Example-11-ReplaceGPOOwnerAutomated.ps1 index 98557e5..6856f6e 100644 --- a/Examples/Example-11-ReplaceGPOOwnerAutomated.ps1 +++ b/Examples/Example-11-ReplaceGPOOwnerAutomated.ps1 @@ -7,7 +7,7 @@ $GPOs = Get-GPOZaurr #-GPOName 'New Group Policy Object' $GPOs | Format-Table DisplayName, Owner, OwnerSID, OwnerType -Set-GPOZaurrOwner -Type EmptyOrUnknown -Verbose -LimitProcessing 1 -WhatIf +Set-GPOZaurrOwner -Type NonAdministrative -Verbose -LimitProcessing 1 -WhatIf $GPOs = Get-GPOZaurr #-GPOName 'New Group Policy Object' $GPOs | Format-Table DisplayName, Owner, OwnerSID \ No newline at end of file diff --git a/Examples/Example-16-AddRemoveGPOPermission.ps1 b/Examples/Example-16-AddRemoveGPOPermission.ps1 index b70f3e7..1c5b947 100644 --- a/Examples/Example-16-AddRemoveGPOPermission.ps1 +++ b/Examples/Example-16-AddRemoveGPOPermission.ps1 @@ -18,25 +18,4 @@ Invoke-GPOZaurrPermission -Linked Root -Verbose { #-IncludePermissionType GpoEdi Remove-GPOPermission -Type NotAdministrative, NotWellKnownAdministrative -IncludePermissionType GpoEdit, GpoEditDeleteModifySecurity Add-GPOPermission -Type Administrative -IncludePermissionType GpoEditDeleteModifySecurity #Add-GPOPermission -Type WellKnownAdministrative -IncludePermissionType GpoEditDeleteModifySecurity -} #-WhatIf #| Format-Table * -#-ApprovedGroups $ApprovedGroups -Trustee $RootGroups -TrusteeType Name -TrusteePermissionType GpoEditDeleteModifySecurity -WhatIf | Format-Table * - - -return -Get-GPOZaurrLink -Linked Root | ForEach-Object { - Get-GPOZaurrPermission -GPOGuid $_.GUID -IncludePermissionType 'GpoEdit', 'GpoEditDeleteModifySecurity' -Type 'NotAdministrative', 'NotWellKnownAdministrative' -IncludeGPOObject | ForEach-Object { - $_ - } -} | Format-Table -a * - -#Get-GPOZaurrLink -Linked Site | Format-Table -AutoSize - -#Get-GPOZaurrLink -Linked DomainControllers | Format-Table -AutoSize - -#Get-GPOZaurrLink -Linked Other | Format-Table -AutoSize - -#Get-GPOZaurrLink -SearchBase 'CN=Configuration,DC=ad,DC=evotec,DC=xyz' | Format-Table -AutoSize - -#Get-AdObject -SearchBase 'DC=ad,DC=evotec,DC=xyz' -Server 'ad.evotec.xyz' -Filter "(ObjectClass -eq 'site') -or (ObjectClass -eq 'organizationalUnit' -or ObjectClass -eq 'domainDNS')" -SearchScope Subtree # - -#Get-ADObject -SearchBase 'CN=Configuration,DC=ad,DC=evotec,DC=xyz' | fl \ No newline at end of file +} #-WhatIf #| Format-Table * \ No newline at end of file diff --git a/GPOZaurr.psd1 b/GPOZaurr.psd1 index 374efb4..e9efe03 100644 --- a/GPOZaurr.psd1 +++ b/GPOZaurr.psd1 @@ -17,7 +17,7 @@ } } RequiredModules = @{ - ModuleVersion = '0.0.137' + ModuleVersion = '0.0.138' ModuleName = 'PSSharedGoods' Guid = 'ee272aa8-baaa-4edf-9f45-b6d6f7d844fe' }, @{ diff --git a/Private/Get-PrivGPOZaurrLInk.ps1 b/Private/Get-PrivGPOZaurrLInk.ps1 index 0fedd33..1b74b55 100644 --- a/Private/Get-PrivGPOZaurrLInk.ps1 +++ b/Private/Get-PrivGPOZaurrLInk.ps1 @@ -8,19 +8,21 @@ if ($Object.GpLink -and $Object.GpLink.Trim() -ne '') { $Object.GpLink -split { $_ -eq '[' -or $_ -eq ']' } -replace ';0' -replace 'LDAP://' | ForEach-Object -Process { if ($_) { + $DomainCN = ConvertFrom-DistinguishedName -DistinguishedName $_ -ToDomainCN $Output = [ordered] @{ DistinguishedName = $Object.DistinguishedName CanonicalName = $Object.CanonicalName Guid = [Regex]::Match( $_, '(?={)(.*)(?<=})').Value -replace '{' -replace '}' } + $Search = -join ($DomainCN, $Output['Guid']) if ($GPOCache -and -not $Limited) { - $Output['DisplayName'] = $GPOCache[$Output['Guid']].DisplayName - $Output['DomainName'] = $GPOCache[$Output['Guid']].DomainName - $Output['Owner'] = $GPOCache[$Output['Guid']].Owner - $Output['GpoStatus'] = $GPOCache[$Output['Guid']].GpoStatus - $Output['Description'] = $GPOCache[$Output['Guid']].Description - $Output['CreationTime'] = $GPOCache[$Output['Guid']].CreationTime - $Output['ModificationTime'] = $GPOCache[$Output['Guid']].ModificationTime + $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['GPODomainDistinguishedName'] = ConvertFrom-DistinguishedName -DistinguishedName $_ -ToDC $Output['GPODistinguishedName'] = $_ @@ -30,19 +32,21 @@ } elseif ($Object.LinkedGroupPolicyObjects -and $Object.LinkedGroupPolicyObjects.Trim() -ne '') { $Object.LinkedGroupPolicyObjects -split { $_ -eq '[' -or $_ -eq ']' } -replace ';0' -replace 'LDAP://' | ForEach-Object -Process { if ($_) { + $DomainCN = ConvertFrom-DistinguishedName -DistinguishedName $_ -ToDomainCN $Output = [ordered] @{ DistinguishedName = $Object.DistinguishedName CanonicalName = $Object.CanonicalName Guid = [Regex]::Match( $_, '(?={)(.*)(?<=})').Value -replace '{' -replace '}' } + $Search = -join ($DomainCN, $Output['Guid']) if ($GPOCache -and -not $Limited) { - $Output['Name'] = $GPOCache[$Output['Guid']].DisplayName - $Output['DomainName'] = $GPOCache[$Output['Guid']].DomainName - $Output['Owner'] = $GPOCache[$Output['Guid']].Owner - $Output['GpoStatus'] = $GPOCache[$Output['Guid']].GpoStatus - $Output['Description'] = $GPOCache[$Output['Guid']].Description - $Output['CreationTime'] = $GPOCache[$Output['Guid']].CreationTime - $Output['ModificationTime'] = $GPOCache[$Output['Guid']].ModificationTime + $Output['Name'] = $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['GPODomainDistinguishedName'] = ConvertFrom-DistinguishedName -DistinguishedName $_ -ToDC $Output['GPODistinguishedName'] = $_ diff --git a/Public/Get-GPOZaurrLink.ps1 b/Public/Get-GPOZaurrLink.ps1 index 3dfaf64..53d1228 100644 --- a/Public/Get-GPOZaurrLink.ps1 +++ b/Public/Get-GPOZaurrLink.ps1 @@ -23,7 +23,7 @@ foreach ($Domain in $ForestInformation.Domains) { $QueryServer = $ForestInformation['QueryServers'][$Domain]['HostName'][0] Get-GPO -All -DomainName $Domain -Server $QueryServer | ForEach-Object { - $GPOCache[$_.ID.Guid] = $_ + $GPOCache["$Domain$($_.ID.Guid)"] = $_ } } }