function Set-ExitCodeAndExit {
[CmdletBinding(SupportsShouldProcess=$True,DefaultParameterSetName="None")]
PARAM(
[Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true, ParameterSetName="p1")]
[int]
$ExitCode
)
Write-Verbose "Setting ExitCode to $($ExitCode) and exiting..."
# When a PowerShell script is called from a batch file or Command Prompt, this line allows a return code back to the calling shell
$host.SetShouldExit($ExitCode)
exit $ExitCode
}