Powershell Script to Create Active Directory Security Group and Shared Mailbox Exchange 2016 Windows 2012 R2
Import-Module ActiveDirectory
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.SnapIn;
$displayname = Read-Host -Prompt 'Input the display name'
$groupname = $displayname + “-mbx”
#Creates the Security Group, then makes it Distribution Group for Exchange
NEW-ADGroup –name $groupname –groupscope Universal –path “OU=SECURITY,OU=GROUPS,OU=OCU,DC=domain,DC=edu”
Enable-DistributionGroup -Identity $groupName
#Example
#New-Mailbox -Shared -Name $displayname -DisplayName $displayname -Alias $displayname | Set-Mailbox -GrantSendOnBehalfTo $groupname | Add-MailboxPermission -Group $groupname -AccessRights FullAccess -InheritanceType All
#Creates the Shared Mailbox then gives full rights of the Group to that MBX and then gives SendAs permissions
New-Mailbox -Shared -Name $displayname -DisplayName $displayname -Alias $displayname
Add-MailboxPermission -Identity $displayname -User $groupname -AccessRights FullAccess -InheritanceType All
Set-Mailbox -Identity $displayname -GrantSendOnBehalfTo $groupname
#This Grants the SendAs Permission
Add-RecipientPermission $displayname -AccessRights SendAs -Trustee $groupname -Confirm:$False
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.