Microsoft Surface Hub 2 SmCamera User Manual
Page 516
{
CleanupAndFail(
"Failed to connect to exchange. Please check your
credentials and try again. If this continues to fail, you may not have
permission for remote powershell - if not, please perform the setup
manually. Error message: $_"
)
}
PrintSuccess
"Connected to Remote Exchange Shell"
try
{
$sessLync =
New-PSSession
-Credential
$credLync
-ConnectionURI
"https://$strLyncFQDN/OcsPowershell"
-AllowRedirection -WarningAction
SilentlyContinue
}
catch
{
CleanupAndFail(
"Failed to connect to Lync. Please check your credentials
and try again. Error message: $_"
)
}
PrintSuccess
"Connected to Lync Server Remote PowerShell"
Import-PSSession
$sessExchange
-AllowClobber -WarningAction
SilentlyContinue
Import-PSSession
$sessLync
-AllowClobber -WarningAction
SilentlyContinue
## Create the Exchange mailbox ##
> [!Note]
> These exchange commandlets
do
not always
throw
their errors as exceptions
# Because Get-Mailbox will throw an error if the mailbox is not found
$Error.Clear()
PrintAction
"Creating a new account..."
try
{
$mailbox =
$null
$mailbox = (
New-Mailbox
-UserPrincipalName
$credNewAccount.UserName
-
Alias
$credNewAccount.UserName.substring(0,$credNewAccount.UserName.indexOf(
'@'
))
-room -Name
$strDisplayName
-RoomMailboxPassword
$credNewAccount.Password
-
EnableRoomMailboxAccount
$true
)
} catch { }
ExitIfError
"Failed to create a new mailbox on exchange."
;
$status[
"Mailbox Setup"
] =
"Successfully created a mailbox for the new
account"
$strEmail = $mailbox.WindowsEmailAddress
PrintSuccess
"The following mailbox has been created for this room:
$strEmail"
## Create or retrieve a policy that will be applied to surface hub devices
##
# The policy disables requiring a device password so that the SurfaceHub
does not need to be lockable to use Active Sync
$strPolicy =
Read-Host
'Please enter the name for a new Surface Hub