Microsoft Surface Hub 2 SmCamera User Manual
Page 526
![background image](/files/873833/content/doc526.png)
{
# Loop until resource type goes away, up to 5 times
for
($i = 0; $i -lt 5
-And
(
Get-Mailbox
$credNewAccount.UserName).ResourceType; $i++)
{
Start-Sleep
-s
5
}
# If the mailbox is still a Room we cannot apply the policy
if
(!((
Get-Mailbox
$credNewAccount.UserName).ResourceType))
{
$Error.Clear()
# Set policy for account
Set-CASMailbox
$credNewAccount.UserName
-ActiveSyncMailboxPolicy
$strPolicy
if
(!$Error)
{
$status[
"Device Password Policy"
] =
"Successfully applied
$strPolicy to the account"
}
else
{
$status[
"Device Password Policy"
] =
"Failed to apply the EAS
policy to the account."
PrintError
"Failed to apply policy"
}
$Error.Clear()
# Convert back to room mailbox
Set-Mailbox
$credNewAccount.UserName
-Type
Room
# Loop until resource type goes back to room
for
($i = 0; ($i -lt 5)
-And
((
Get-Mailbox
$credNewAccount.UserName).ResourceType -ne
"Room"
); $i++)
{
Start-Sleep
-s
5
}
if
((
Get-Mailbox
$credNewAccount.UserName).ResourceType -ne
"Room"
)
{
# A failure to convert the mailbox back to a room is
unfortunate but means the mailbox is unusable.
$status[
"Mailbox Setup"
] =
"A mailbox was created but we
could not set it to a room resource type."
}
else
{
Set-Mailbox
$credNewAccount.UserName
-RoomMailboxPassword
$credNewAccount.Password
-EnableRoomMailboxAccount
$true
if
($Error)
{
$status[
"Mailbox Setup"
] =
"A room mailbox was created
but we could not set its password."
}
$Error.Clear()
}