Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

List AD Security group members and exclude specific entries

$
0
0

Hey guys,

I want to list all the members of a security group, lets say 'Group'. I then want to remove specific servers (in this case, our SCOM Management servers) from the list that gets returned (which I then later want to run a 'foreach' loop on.

I've done something like the following;

 

$groupMembers = Get-ADGroupMember "Group" -recursive | Select-Object Name
$scomMgmtSvrs = Get-SCOMManagementServer | Select-Object DisplayName

 

ForEach ($scomServer in $scomMgmtSvrs) { # Remove this entry from $groupMembers }

 

# So that later I can..

 

ForEach ($member in $groupMembers) { #Do Things }

 

How can I achieve this?

Thanks.


Viewing all articles
Browse latest Browse all 6937

Trending Articles