Active Directory & GPO Weekly Information Pull
PowerShell
Active Directory
GPO
Reporting
Purpose: Generate a weekly snapshot of AD posture and GPO changes for visibility and audit readiness.
- Exports privileged group membership and basic account status indicators.
- Produces GPO reports and highlights recently modified policies.
- Outputs to CSV/HTML for review and reporting.
View sample code
# Weekly AD + GPO Report (Sample)
# NOTE: Replace placeholders and adapt to your environment.
Import-Module ActiveDirectory
Import-Module GroupPolicy
$ReportPath = "C:\Reports"
New-Item -ItemType Directory -Path $ReportPath -Force | Out-Null
# Privileged groups to track
$PrivGroups = @("Domain Admins","Enterprise Admins","Administrators")
$PrivReport = foreach ($g in $PrivGroups) {
Get-ADGroupMember -Identity $g -Recursive |
Select-Object @{Name="Group";Expression={$g}}, Name, SamAccountName, ObjectClass
}
$PrivReport | Export-Csv "$ReportPath\PrivilegedGroups.csv" -NoTypeInformation
# GPO HTML Reports
$AllGpos = Get-GPO -All
foreach ($gpo in $AllGpos) {
Get-GPOReport -Guid $gpo.Id -ReportType Html -Path "$ReportPath\GPO_$($gpo.DisplayName).html"
}
Write-Host "Report generated at $ReportPath"