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

Getting users groupmemberships where the group SAM is *-dg

$
0
0

So as per the topic.

I'm making a script to "pause" users that go on vacation but i'm having trouble in getting the users distributiongroups.

I know i can use Get-Distributiongroup, but i don't want to remote session to the exchange server, and instead i want to use AD groups for it.

All our distribution groups have a matching security group but dgs always have a samaccountname that end in -dg.

eg.

Security group: sysadmin

Distribution group: sysadmin-dg

 

Tried this one-liner but it returns... well... nothing

 

(Get-ADPrincipalGroupMembership-Identity$UserName).samaccountname | where {$_.samaccountname-like"-dg"}

Viewing all articles
Browse latest Browse all 6937

Trending Articles