Add Admin Permission to User Mailbox
Introduction
This script will grant Admin Role and Full Access Permission to the User Mailbox.
Scenarios
This script is to help Exchange Administrators to grant Admin Role and Full Access Permission via PowerShell.
Script
This script contains two advanced functions Add-OSCAdminPermission and Remove-OSCAdminPermission, you can use this script in the following ways:
Step1: Run the script in the Exchange Management Shell, type the one command: Import-Module <Script Path> at the prompt.
For example, type Import-Module C:\Script\AddAdminPermission.psm1
Here are some code snippets for your references.
$Check = Get-Mailbox $mbx -ErrorAction SilentlyContinue
if($check){
#Check if the role is existed
$mbxName = $check.Name
$checkrole = Get-RoleGroupMember "Organization Management" | where{$_.name -eq $mbxName}
if($checkrole){
#remove Roles
Remove-RoleGroupMember "Organization Management" -Member $mbxName -confirm:$false
#remove full access
Get-Mailbox -Resultsize unlimited | Remove-Mailboxpermission â€"User $mbxName â€"Accessrights Fullaccess -confirm:$false | Out-Null
Write-Host "Mailbox User $mbx is now without Admin Role and Full Access Permission to all Mailboxes"
}
else{
Write-Host "Couldn't find $mbxName in admin group."
}
}
$Check = Get-Mailbox $mbx -ErrorAction SilentlyContinue
if($check){
#Check if the role is existed
$mbxName = $check.Name
$checkrole = Get-RoleGroupMember "Organization Management" | where{$_.name -eq $mbxName}
if($checkrole){
#remove Roles
Remove-RoleGroupMember "Organization Management" -Member $mbxName -confirm:$false
#remove full access
Get-Mailbox -Resultsize unlimited | Remove-Mailboxpermission â€"User $mbxName â€"Accessrights Fullaccess -confirm:$false | Out-Null
Write-Host "Mailbox User $mbx is now without Admin Role and Full Access Permission to all Mailboxes"
}
else{
Write-Host "Couldn't find $mbxName in admin group."
}
}
Examples
Example 1: Grant Admin Role and Full Access Permission for mailbox "Test1".
Command: Add-OSCAdminPermission -Mailbox "Test1"
Screenshot:
Example 2: Remove Admin Role and Full Access Permission for mailbox "Test1","Test2".
Command: Remove-OSCAdminPermission -Mailbox "Test1","Test2"
Screenshot:
Prerequisite
Exchange 2010 and above Exchange Version
English Version only
PowerShell 2.0
Microsoft All-In-One Script Framework is an automation script sample library for IT Professionals. The key value that All-In-One Script Framework is trying to deliver is Scenario-Focused Script Samples driven by IT Pros' real-world pains and needs. The team is monitoring all TechNet forums, IT Pros' support calls to Microsoft, and script requests submitted to TechNet Script Repository. We collect frequently asked IT scenarios, and create script samples to automate the tasks and save some time for IT Pros. The team of All-In-One Script Framework sincerely hope that these customer-driven automation script samples can help our IT community in this script-centric move.