PowerShell Script to Report All Group Policy Links by Ashley McGlone. Forensics: Audit Group Policy Links and Changes with PowerShell by Ashley McGlone.
Get-ADOrganizationalUnit -Filter * | ` Get-GPInheritance | ` Where-Object {$_.GpoLinks -ne $null} | ` Select-Object Path, @{Name = 'GpoLinks';Expression = {[string]::join(', ',$_.GpoLinks.DisplayName)}} | ` Sort-Object Path | ` Export-Csv -Delimiter ";" -NoTypeInformation -Path "C:\TEMP\result.csv"