Avatar of Albert Widjaja
Albert Widjaja
Flag for Australia asked on

Modifying AD Group Policy Powershell to list unused GPO

I had this question after viewing Powershell to list unused Group Policy Object ?.

Hi,

Can anyone here please assist me in modifying the Powershell script below to add additional testing:

Some of the Group Policy Object is not linked to any OU but it has got Security Filtering with some AD security group and AD user account listed.

$result = @();

$AllGPOs = Get-GPO -All
foreach ($gpo in $AllGPOs)
{
 [xml]$report = Get-GPOReport -Name "$($gpo.DisplayName)" -ReportType Xml
 If ($report.GPO.LinksTo -eq $null -or ($gpo.Computer.DSVersion -eq 0 -and $gpo.User.DSVersion -eq 0))
 {
  # Report and Export to .CSV file
  $temp = "" | Select Name, Status;
  $temp.Name = $gpo.DisplayName;
  $temp.Status = $gpo.GpoStatus;
  $result += $temp;
  
 } 
}
$result | Export-Csv -Path C:\Unused.csv -NoTypeInformation

Open in new window


So the checking should be Unlinked AD group AND the Security filtering that is empty.

Thanks in advance.
PowershellActive DirectorySecurity

Avatar of undefined
Last Comment
Shaun Vermaak

8/22/2022 - Mon
Shaun Vermaak

So the checking should be Unlinked AD group AND the Security filtering that is empty.
Just a question... If GPO is empty or unlinked, why does the security filter matter?
Albert Widjaja

ASKER
Wel, when running the GPO Powershell above,

I can see the GPO is not empty but it has got WMI FIlter ?
SOLUTION
compdigit44

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Albert Widjaja

ASKER
OK,

what I have found from running the Powershell above is that some GPO has WMI filter and members in the Security Filtering.

So is it enough to trust the result of the Script above ?
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
ASKER CERTIFIED SOLUTION
Shaun Vermaak

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.