Link to home
Start Free TrialLog in
Avatar of IT _Admin0723
IT _Admin0723Flag for United States of America

asked on

Query all GPOs and Security Filtering Groups and Deny Groups

Hello there experts,

I'm trying to run a query to query all GPOs in our environment and its corresponding security filtering groups (GpoApply) plus deny apply which shows us (GpoCustom), and pipe it to an output file. I have the following but for some reason it's not filtering using the "where" parameter. Can someone please help? THank you so much!

Import-Module GroupPolicy
$perms = Foreach ($GPO in (Get-GPO -All -domain contoso.com))
{
   Foreach ($Perm in (Get-GPPermissions $GPO.DisplayName -All -domain contoso.com))
   {
      New-Object PSObject -property @{GPO=$GPO.DisplayName;Trustee=$Perm.Trustee.Name;Permission=$Perm.Permission} | Where {$_.Permission -eq "GpoApply" -or "GpoCustom"}
   }

   $perms | Select GPO,Trustee,Permission | Format-Table -AutoSize

}

$perms | out-file c:\temp\results.txt
ASKER CERTIFIED SOLUTION
Avatar of footech
footech
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of IT _Admin0723

ASKER

Thank you!
Is this script reporting something or renaming the Group Policy name & permission?