From 3fe52c99b53954566a1ffd453dbd2fb90e071303 Mon Sep 17 00:00:00 2001 From: Przemyslaw Klys Date: Mon, 28 Dec 2020 09:55:14 +0100 Subject: [PATCH] Private use only --- Private/Get-GPOPrivInheritanceLoop.ps1 | 4 +- .../Get-GPOZaurrLinkInheritance.ps1 | 68 ++++++++++++++++++- 2 files changed, 67 insertions(+), 5 deletions(-) rename {Public => Private}/Get-GPOZaurrLinkInheritance.ps1 (80%) diff --git a/Private/Get-GPOPrivInheritanceLoop.ps1 b/Private/Get-GPOPrivInheritanceLoop.ps1 index d0fd7e3..2efc3f7 100644 --- a/Private/Get-GPOPrivInheritanceLoop.ps1 +++ b/Private/Get-GPOPrivInheritanceLoop.ps1 @@ -4,7 +4,7 @@ function Get-GPOPrivInheritanceLoop { [Microsoft.ActiveDirectory.Management.ADObject[]] $ADObject, [System.Collections.IDictionary] $CacheReturnedGPOs, [System.Collections.IDictionary] $ForestInformation, - [validateset('Root', 'DomainControllers', 'Other')][string[]] $Linked, + [validateset('Root', 'DomainControllers', 'OrganizationalUnit')][string[]] $Linked, [string] $SearchBase, [Microsoft.ActiveDirectory.Management.ADSearchScope] $SearchScope, [string] $Filter @@ -44,7 +44,7 @@ function Get-GPOPrivInheritanceLoop { # Sites are defined only in primary domain # Sites are not supported by Get-GPInheritance } - if ($Linked -contains 'Other') { + if ($Linked -contains 'OrganizationalUnit') { $SearchBase = $ForestInformation['DomainsExtended'][$Domain]['DistinguishedName'] $Splat['Filter'] = "(objectClass -eq 'organizationalUnit')" $Splat['SearchBase'] = $SearchBase diff --git a/Public/Get-GPOZaurrLinkInheritance.ps1 b/Private/Get-GPOZaurrLinkInheritance.ps1 similarity index 80% rename from Public/Get-GPOZaurrLinkInheritance.ps1 rename to Private/Get-GPOZaurrLinkInheritance.ps1 index 0e44524..5934c35 100644 --- a/Public/Get-GPOZaurrLinkInheritance.ps1 +++ b/Private/Get-GPOZaurrLinkInheritance.ps1 @@ -1,4 +1,65 @@ function Get-GPOZaurrLinkInheritance { + <# + .SYNOPSIS + Short description + + .DESCRIPTION + Long description + + .PARAMETER ADObject + Parameter description + + .PARAMETER Filter + Parameter description + + .PARAMETER SearchBase + Parameter description + + .PARAMETER SearchScope + Parameter description + + .PARAMETER Linked + Parameter description + + .PARAMETER Limited + Parameter description + + .PARAMETER SkipDuplicates + Parameter description + + .PARAMETER GPOCache + Parameter description + + .PARAMETER Forest + Parameter description + + .PARAMETER ExcludeDomains + Parameter description + + .PARAMETER IncludeDomains + Parameter description + + .PARAMETER ExtendedForestInformation + Parameter description + + .PARAMETER AsHashTable + Parameter description + + .PARAMETER Summary + Parameter description + + .EXAMPLE + $Output = Get-GPOZaurrLinkInheritance -Summary + $Output | Format-Table + + $Output[5] + + $Output[5].Links | Format-Table + $Output[5].LinksObjects | Format-Table + + .NOTES + This is based on Get-GPInheritance which isn't ideal and doesn't support sites. Get-GPOZaurrLink is better. Leaving in case I need it later on for private use only. + #> [cmdletbinding(DefaultParameterSetName = 'All')] param( [parameter(ParameterSetName = 'ADObject', ValueFromPipeline, ValueFromPipelineByPropertyName, Mandatory)][Microsoft.ActiveDirectory.Management.ADObject[]] $ADObject, @@ -7,7 +68,7 @@ function Get-GPOZaurrLinkInheritance { [parameter(ParameterSetName = 'Filter')][string] $SearchBase, [parameter(ParameterSetName = 'Filter')][Microsoft.ActiveDirectory.Management.ADSearchScope] $SearchScope, - [parameter(ParameterSetName = 'Linked', Mandatory)][validateset('Root', 'DomainControllers', 'Other')][string[]] $Linked, + [parameter(ParameterSetName = 'Linked', Mandatory)][validateset('Root', 'DomainControllers', 'OrganizationalUnit')][string[]] $Linked, [parameter(ParameterSetName = 'Filter')] [parameter(ParameterSetName = 'ADObject')] @@ -71,8 +132,9 @@ function Get-GPOZaurrLinkInheritance { } Process { if (-not $Filter -and -not $Linked) { - # We choose ALL - #$Linked = 'Root', 'DomainControllers', 'Site', 'Other' + # We choose ALL, except SITE which is not supported gor Get-GPInheritance + # that's why it's better to use Get-GPOZaurrLink + #$Linked = 'Root', 'DomainControllers', 'Site', 'OrganizationalUnit' } $getGPOPrivInheritanceLoopSplat = @{ Linked = $Linked