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"}