foreach filtering out members already apart of group

前端 未结 2 1161
你的背包
你的背包 2021-01-25 16:37
$GetGroupsFromUser = Get-ADPrincipalGroupMembership $WPFnamelookupbox.Text |
                     Where-Object { $_.Name -like \'G1*\' }
$Groups = Get-ADGroup -Filter {N         


        
2条回答
  •  醉话见心
    2021-01-25 17:39

    You could use Compare-Object:

    $GetGroupsFromUser = Get-ADPrincipalGroupMembership $WPFnamelookupbox.Text | Where-Object {$_.name -like 'G1*' }
    $Groups = Get-ADGroup -Filter "name -like 'G1*'"
    Compare-Object $Groups $GetGroupsFromUser | Where-Object {$_.SideIndicator -eq "<="}
    

提交回复
热议问题