Hi Glenn Maxwell,
Import-Module ActiveDirectory
$searchBase = "OU=Groups,DC=my,DC=domain-int,DC=com"
$outputPath = "C:\path\to\exported_groups.csv"
Get-ADGroup -Filter * -SearchBase $searchBase -SearchScope Subtree -Properties Description | Select-Object Name, GroupCategory, Description, @{Name="OU Path"; Expression={($_.DistinguishedName -split '(?<!\\),', 2)[1]}} | Export-Csv -Path $outputPath -NoTypeInformation -Encoding UTF8
You can safely execute this script in an elevated PowerShell console on a domain-joined machine. The script extracts the exact parent structural path by processing the distinguished name property with a calculated regular expression, splitting the string perfectly to remove the group's relative name while preserving the actual directory location. Be sure to replace the placeholder search base string with the exact distinguished name of your target organizational unit and update the local C:\ drive destination path for the CSV output file.
Hope this answer has brought you some useful information. If it did, please hit “accept answer”. Should you have any questions, feel free to leave a comment.
VPHAN