(Get-CalendarProcessing -Identity “MyAwesomeRoom”).ResourceDelegates is equal to (Get-Mailbox -Identity “MyAwesomeRoom”).GrantSendOnBehalfTo. This is good to know, because while you can do Set-Mailbox -GrantSendOnBehalfTo @{add=”user3@awesome.com”} and not kick out user1 and user2, Set-CalendarProcessing does not do this. If you try it, you get back this mess:
Cannot process argument transformation on parameter ‘ResourceDelegates’. Cannot convert the “System.Collections.Hashtable”
value of type “System.Collections.Hashtable” to type “Microsoft.Exchange.Configuration.Tasks.RecipientIdParameter[]”.
Unfortunately, I have yet to find a similar, more friendly route for adding BookInPolicy, RequestInPolicy or RequestOutOfPolicy.
All of these parameters will take an array, so you need to read in what’s there, append your new delegate(s), then write the new list to Set-CalendarProcessing:
function Add-CalendarResourceDelegate { Param( $roomName , $newDelegate ) $resourceDelegates = (Get-CalendarProcessing -Identity $roomName).ResourceDelegates $resourceDelegates += $newDelegate Set-CalendarProcessing -Identity $roomName -ResourceDelegates $resourceDelegates }
function Add-CalendarBookInPolicy { Param( $roomName , $newDelegate ) $bookInPolicy = (Get-CalendarProcessing -Identity $roomName).BookInPolicy $bookInPolicy += $newDelegate Set-CalendarProcessing -Identity $roomName -BookInPolicy $bookInPolicy }
Add-CalendarResourceDelegate -roomName “MyAwesomeRoom” -newDelegate user3
Removing delegates is a bit trickier; they are stored in the array as canonical names (awesome.com/Site1/Users/user1), not email or UserPrincipalName (User.One@awesome.com or user1@awesome.com). However, you just need to do (Get-Mailbox user1).Identity to get this.
function Remove-CalendarResourceDelegate { Param( $roomName , $delegateToRemove ) $resourceDelegates = (Get-CalendarProcessing -Identity $roomName).ResourceDelegates $delegateToRemoveIdentity = (Get-Mailbox $delegateToRemove).Identity $resourceDelegates.Remove($delegateToRemoveIdentity) Set-CalendarProcessing -Identity $roomName -ResourceDelegates $resourceDelegates }
And so on for BookInPolicy, RequestInPolicy and RequestOutOfPolicy.
A step closer to extending ActiveRoles Server to handle all the Set-CalendarProcessing attributes…
Thanks for the article I found it useful for configuring Set-MailboxSearch with multiple source mailboxes.
LikeLike
Always great to hear about something helping someone out – thanks for taking the time to comment!
LikeLike
Great One… helped a lot. 🙂
Is there any other way to Add a list of users from .csv or .txt file in book-in policy in o365 hybrid environment.
Something like below I tried
$users=get-content .\users.txt
Set-Calenderprocessing “MeetRoom” -bookinpolicy $users
But this removes all of the current users 😦
Happy to hear from you 🙂
LikeLike
Hi Jitendra,
While I’ve not done anything with O365 mailboxes, I assume that Set-CalendarProcessing works similarly to on-prem, and my function Add-CalendarBookInPolicy is what you want.
LikeLike
Thanks Amanda. 🙂
I was not able to remove users from bookinpolicy. Figured out below and it worked like a charm. 🙂
Removing user from BookInPolicy:
function Remove-UserBookInPolicy {
Param(
$roomName
, $UserToRemove
)
$bookinUsers = (Get-CalendarProcessing -Identity $roomName).BookInPolicy
$UserToRemoveIdentity = (Get-Mailbox $UserToRemove).LegacyExchangeDN
$bookinUsers.Remove($UserToRemoveIdentity)
Set-CalendarProcessing -Identity $roomName -BookInpolicy $bookinUsers
}
LikeLike
Very cool – thanks for sharing!
LikeLike
Hi 🙂
I’ve come to weird situation -I put your add and remove function into a foreach loop but for things to work I also had to put a SLEEP 5 sec – like this:
$confs = Import-CSV “C:\!Scripts\confrooms.csv”
$delegs= Import-CSV “C:\!Scripts\delegates.csv”
Foreach ($conf in $confs){
foreach ($deleg in $delegs) {
Add-CalendarResourceDelegate -roomName $conf.room -newDelegate $deleg.deleg
Start-Sleep -Seconds 5
}
}
Same for Remove:
$confs = Import-CSV “C:\!Scripts\confrooms.csv”
$delegs= Import-CSV “C:\!Scripts\delegates.csv”
Foreach ($conf in $confs){
foreach ($deleg in $delegs) {
Remove-CalendarResourceDelegate -roomName $conf.room -DelegateToRemove $deleg.deleg
Start-Sleep -Seconds 5
}
}
without sleep only last username listed in delegates.csv file has been added or removed ! Dunno why – maybe You have some insights for this ?
hava a great day
Marek Godlewski
LikeLike
Thank you for posting this! Huge help.
LikeLike