The actual links to a group policy object are stored in the organizational unit, domain, or site objects, in the attribute gpLink. It is a single-valued string attribute that holds all of the gpo's, delimited with each gpo object enclosed in brackets [].
The gPLink attribute holds a list of all Group Policy containers linked to the container and a number for each listed Group Policy container, that represents the Enforced (previously known as No Override) and Disabled option settings. The list appears in priority order from lowest to highest priority GPO.
If you wanted to do this manually, you could perform a global catalog query of all objects that have that attribute (gpLink=*). If you combine this with the output of the gpmc backup, you should be all set.
$searcher = New-Object system.DirectoryServices.DirectorySearcher
$searcher.SearchRoot=[adsi]"GC://dc=domainname,dc=acme,dc=com"
#$searcher.SearchScope="subtree" #if you have child domains
$searcher.PageSize=1000
$searcher=[adsisearcher]"(gpLink=*)"
$searcher.ClientTimeout=600
$ADResults = @()
$results=$searcher.FindAll()
foreach ($result in $results) {
$tempObj = New-Object psObject
$adProperties = $result.properties
foreach ($propertyName in $adProperties.propertyNames) {
if (@($adProperties.item($propertyName)).count -gt 1) {
$tempObj | Add-Member -MemberType noteproperty -Name $propertyName -Value $adProperties.item($propertyName)}
else {
$tempObj | Add-Member -MemberType noteproperty -Name $propertyName -Value ($adProperties.item($propertyName) | Out-String -Width 4096).trim()}
} # end foreach $propertyName
$ADResults += $tempObj
} # end foreach $result
$ADResults | select distinguishedName, gpLink | Out-File results.txt -Width 4096
Some of the links can be quite numerous. If you can find an occurrence of ... in the results file, that means you need a larger output buffer than 4096.
You may also find it useful to perform a query for objects that have the gpOptions attribute set. The gPOptions attribute contains the Block Policy Inheritance setting. It holds an integer value that indicates whether the Block Policy Inheritance option of a domain or OU is enabled (0) or disabled (1).