共用方式為


HOW TO: Add ResourceDelegates for a Room Mailbox(s) based on a specified criteria using Powershell script

If you want to add ResourceDelegates for a Room Mailbox based on a specific criteria you can use the script below:

In this case we add all users in a specific database as ResourceDelegates

Create a .PS1 file as below:

 #This function returns all the users from a specific Database
#This function can be altered to return mailboxes based on any other criteriaFunction GetUsers
{
    param($DbName="")
    $UMailboxes="" 

    $UMailboxes =Get-Mailbox -Database $DbName -RecipientTypeDetails Usermailbox 

    return $UMailboxes
} 

#Get the Room Mailboxes for which we have to set the Delegates
#In this case we have to set the Delegates for the Room Mailbox tproom

Get-Mailbox -identity tproom -RecipientTypeDetails RoomMailbox | 
foreach{ 
 #Call the GetUsers function passing in the Database name. 
 Set-MailboxCalendarSettings -Identity $_.Alias
    -ResourceDelegates (GetUsers "ex200701\First Storage Group\Mailbox Database") 
}

To Run the script:

1)Open the Exchange Management Shell

2)Navigate to the location where you have stored the script file.

3)Type in .\ScriptName.PS1 and hit enter to execute the script.