Enumerating GPOs
To enumerate which GPOs were linked in the current environment, you can use ADSI accelerators:
By using the [adsi] accelerator, you can provide a DistinguishedName path to show the gplink property, which will display the GPOs linked to that particular path. To query a GPO that was linked to the PSSecComputers OU (OU=PSSecComputers,DC=PSSec,DC=local), we could use the following code snippet to query it:
$DistinguishedName = "LDAP://OU=PSSecComputers,DC=PSSec,DC=local"
$obj = [adsi]$DistinguishedName
$obj.gplink
The following screenshot shows the result of this query:
Figure 6.2 – Querying GPOs using the ADSI accelerator
You can also use [adsisearcher] to filter for GPOs linked to the environment, as shown in the following example:
$GpoFilter = "(objectCategory=groupPolicyContainer)"
$Searcher = [adsisearcher]$GpoFilter
$Searcher.SearchRoot = [adsi]"LDAP://DC=PSSec,DC=local"...