# retrieve the GPOs linked to AD OU
# initially we need to get the 2 modules AD and GPO
Get-Module activedirectory.grouppolicy
# Create a variable for the OU that we will be looking at
$OU = "OU=ZhyHealth,DC=internal,DC=Zhyhealth,DC=org,DC=au"
# change this OU based on the required lookup
Get-ADOrganizationalUnit $OU
# For this OU the property we will be looking at is the LinkedGroupPolicyObjects
$LinkedGPOs = Get-ADOrganizationalUnit $OU | Select-Object -ExpandProperty LinkedGroupPolicyObjects
$LinkedGPOs
$linkedGPOGUIDs = $LinkedGPOs | ForEach-Object{$_.Substring(4,36)}
$linkedGPOGUIDs
# Now we have retrieved the GUIDs, we need to loop through these GUIDs and use the Get-GPO
# to fetch the DisplayName of GPO
$linkedGPOGUIDs | ForEach-Object {Get-GPO $_ Select-Object DisplayName }