We help IT Professionals succeed at work.

Run Powershell command against members of AD Group

aideb
aideb asked
on
I need to put together a script which will;

1. Enumerate all the members of a domain group (Management-GRP)
2. Run this command for all the members
Add-MailboxPermission -Identity USERNAME -user ManagementSystem-Mailbox-FC -AccessRights FullAccess

Can anyone help?

Comment
Watch Question

Author

Commented:
I have worked some of this out

Get-ADGroupMember "Management-GRP" | Select-Object Name

Gives me the name of all the users

Can someone help tie it together?
Works for me in Exchange 07. Replace the variables with you own. Remove the -WhatIf switch on the end once you've tested it:

Get-DistributionGroupMember -Identity "Enter Group" | ? {$_.RecipientType -eq "UserMailbox"} | % {Add-MailboxPermission -Identity $_.Identity -User "Enter User" -AccessRights "FullAccess" -WhatIf}

Open in new window

Author

Commented:
Thanks for your help