Here's a quick function I created going by your goal:
@pmoncho said in Powershell - Find GPO's for specific Group:
Goal - Find all GPO's that have "SomeGroupName" in Delegation Tab.
I can change it to a script you can run that takes parameters instead if that was how you planned on using it. But as it is below, it's meant to be used within a script or in ISE for example in the screenshots below.
I am using the -eq
, so the parameter you use for -GroupName
needs to be exact. Otherwise, you can change it to -match
for example.
note I only tried this in PS v5.1
function Get-GPOGroupMatches {
[cmdletbinding()]
param(
[Parameter(Mandatory)]
[string]$GroupName
)
$gpos = Get-GPO -All
$list = foreach ($gpo in $gpos) {
if ((Get-GPPermission -Name $gpo.DisplayName -All).Trustee.Name -eq $GroupName) {
[PSCustomObject]@{
GPOName = $gpo.DisplayName
}
}
}
Write-Output -InputObject $list
}
# Example use(s):
# Example 1:
Get-GPOGroupMatches -GroupName "TestGroup1"
# Example 2:
$GPOs = Get-GPOGroupMatches -GroupName "TestGroup1"
$GPOs.GPOName