Microsoft Surface Hub 2 SmCamera User Manual

Page 514

Advertising
background image

PowerShell

# SHAccountCreateOnPrem.ps1

$Error.Clear()
$ErrorActionPreference =

"Stop"

$status = @{}

# Cleans up set state such as remote powershell sessions

function

Cleanup()

{

if

($sessExchange)

{

Remove-PSSession

$sessExchange

}

if

($sessCS)

{

Remove-PSSession

$sessCS

}
}

function

PrintError($strMsg)

{

Write-Host

$strMsg

-foregroundcolor

Red

}

function

PrintSuccess($strMsg)

{

Write-Host

$strMsg

-foregroundcolor

Green

}

function

PrintAction($strMsg)

{

Write-Host

$strMsg

-ForegroundColor

Cyan

}

# Cleans up and prints an error message

function

CleanupAndFail($strMsg)

{

if

($strMsg)

{
PrintError($strMsg);
}
Cleanup

exit

1

}

# Exits if there is an error set and prints the given message

function

ExitIfError($strMsg)

{

if

($Error)

{
CleanupAndFail($strMsg);

Advertising