Get All GPOs from Domain Controller with PowerShell

Опубликовано: 18 Май 2026
на канале: BineshTech
139
2

Get All GPOs from Domain Controller with PowerShell
Get Group Policy Object Info in PowerShell
=================================================

Import-Module GroupPolicy

Ensure the Group Policy module is loaded

$GPOList = @() # Create an empty array to store GPO information

Iterate through all GPOs in the current domain
Get-GPO -All | ForEach-Object {
$GPO = $_

Generate a detailed report for each GPO in XML format
$GPOInfoReport = [xml](Get-GPOReport -Guid $GPO.Id -ReportType XML)

Extract relevant GPO details from the report and create a custom object
$GPOObject = [PSCustomObject]@{
DisplayName = $GPO.DisplayName
#DomainName = $GPO.DomainName
#ID = $GPO.Id
GPOStatus = $GPO.GpoStatus
#Description = $GPO.Description
CreationTime = $GPO.CreationTime
ModificationTime = $GPO.ModificationTime
#UserVersion = $GPO.UserVersion
ComputerVersion = $GPO.ComputerVersion
WmiFilter = $GPO.WmiFilter
LinksPath = $GPOInfoReport.GPO.LinksTo.SOMPath
LinksEnabled = $GPOInfoReport.GPO.LinksTo.Enabled
CompEnabled = $GPOInfoReport.GPO.Computer.Enabled
UserEnabled = $GPOInfoReport.GPO.User.Enabled
Enforced = $GPOInfoReport.GPO.LinksTo.NoOverride
Add other desired properties from $GPO or $GPOInfoReport as needed
}

$GPOList += $GPOObject # Add the GPO object to the list
}

Output the gathered GPO information (you can modify this part to export to CSV, etc.)
$GPOList | Format-Table -AutoSize

To export to a CSV file
$GPOList | Export-Csv -Path "C:\GPO_Details.csv" -NoTypeInformation