IT _Admin0723
asked on
Query GPOs linked to OUs Powershell
Hello experts,
I would like to query GPOs linked to multiple OUs (in DN format) from a file format. I have the following simple array below but would like to ask for your expertise on how to pipe the following results to the following format (columns) to a file.
Column A = OU/DN
Column B = GPO name
Column C = GPO GUID
Column D = Enforced
PS Script:
SDN= Get-Content c:\temp\listofDNsofOUs.txt
Foreach ($DN in $DNs)
(
(Get-GPInheritance -target $dn).gpolinks;
}
Thank you so much!
I would like to query GPOs linked to multiple OUs (in DN format) from a file format. I have the following simple array below but would like to ask for your expertise on how to pipe the following results to the following format (columns) to a file.
Column A = OU/DN
Column B = GPO name
Column C = GPO GUID
Column D = Enforced
PS Script:
SDN= Get-Content c:\temp\listofDNsofOUs.txt
Foreach ($DN in $DNs)
(
(Get-GPInheritance -target $dn).gpolinks;
}
Thank you so much!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
$DNs = Get-Content c:\temp\listofDNsofOUs.txt
$(ForEach ($DN In $DNs) {
Get-GPInheritance -Target $DN |
Select-Object -ExpandProperty GPOLinks |
Select-Object @{n='DN'; e={$DN}}, DisplayName, GpoId, Enforced, Order |
Sort-Object -Property Order
}
)| Export-Csv -NoTypeInformation -Path C:\Temp\GPOLinks.csv