358 lines
10 KiB
PowerShell
358 lines
10 KiB
PowerShell
<#
|
|
.SYNOPSIS
|
|
Create the S4B Related Exchange UM QoS Group Policy
|
|
|
|
.DESCRIPTION
|
|
Create the Skype for Busines related Exchange Unified Messaging Quality of Services Group Policy
|
|
|
|
.EXAMPLE
|
|
PS C:\> .\ExchangeUM_GPO.ps1
|
|
|
|
.EXAMPLE
|
|
PS C:\> .\ExchangeUM_GPO.ps1 -verbose
|
|
|
|
.NOTES
|
|
Check that the ports and port ranges fit your requirements!
|
|
|
|
The ports and ranges we use here should fit the Skype for Business Online setup
|
|
#>
|
|
[CmdletBinding()]
|
|
param ()
|
|
|
|
#Requires -RunAsAdministrator
|
|
|
|
BEGIN
|
|
{
|
|
#region Variables
|
|
|
|
# QoS marking for Audio
|
|
$SC = 'SilentlyContinue'
|
|
$STP = 'Stop'
|
|
[string]$AudioMark = '46'
|
|
|
|
#endregion Variables
|
|
|
|
#region GroupPolicyInfo
|
|
|
|
# GPO (Policy) Name
|
|
[string]$PolicyName = 'S4B QoS - Exchange UM'
|
|
|
|
# GPO (Policy) Comment
|
|
[string]$PolicyComment = 'DSCP markings for Exchange UM traffic. This GPO should be applied to all Organizational Units (OUs) containing Exchange UM servers.'
|
|
|
|
#endregion GroupPolicyInfo
|
|
|
|
#region Defaults
|
|
|
|
# Define some Defaults
|
|
[string]$MinusOne = '-1'
|
|
[string]$OneZero = '1.0'
|
|
[string]$One = '1'
|
|
[string]$WC = '*'
|
|
[string]$ThrotRate = 'Throttle Rate'
|
|
[string]$DscpVal = 'DSCP Value'
|
|
[string]$RemIPLen = 'Remote IP Prefix Length'
|
|
[string]$RemIP = 'Remote IP'
|
|
[string]$RemPort = 'Remote Port'
|
|
[string]$LocIPLen = 'Local IP Prefix Length'
|
|
[string]$LocIP = 'Local IP'
|
|
[string]$LocPort = 'Local Port'
|
|
[string]$Protocol = 'Protocol'
|
|
[string]$AppName = 'Application Name'
|
|
[string]$Version = 'Version'
|
|
[string]$STRG = 'String'
|
|
[string]$UserSettingsDisabled = 'UserSettingsDisabled'
|
|
[string]$ServicesTcpipQoSName = 'HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\QoS'
|
|
[string]$ServicesTcpipQoSValue = 'Do not use NLA'
|
|
[string]$Action = 'Update'
|
|
[string]$Context = 'Computer'
|
|
|
|
#endregion Defaults
|
|
|
|
#region ModuleHandler
|
|
|
|
try
|
|
{
|
|
# List of Modules
|
|
$Modules = 'ActiveDirectory', 'GroupPolicy'
|
|
|
|
# Loop over the Module List
|
|
foreach ($Module in $Modules)
|
|
{
|
|
# Import the Module
|
|
Write-Verbose -Message ('Importing {0}' -f $Module)
|
|
|
|
$null = (Import-Module -Name $Module -ErrorAction $STP -WarningAction $SC)
|
|
|
|
Write-Verbose -Message ('Imported {0}' -f $Module)
|
|
}
|
|
}
|
|
catch
|
|
{
|
|
# Whoops
|
|
Write-Error -Message ('Unable to import the {0} Module, please check your Setup!' -f $Module) -ErrorAction $STP
|
|
|
|
# We are done here...
|
|
break
|
|
}
|
|
|
|
#endregion ModuleHandler
|
|
}
|
|
|
|
PROCESS
|
|
{
|
|
#region CreateGroupPolicy
|
|
|
|
try
|
|
{
|
|
Write-Verbose -Message ('Try to create {0}' -f $PolicyName)
|
|
|
|
#Cleanup
|
|
$paramNewGPO = $null
|
|
|
|
# Splat reusable parameters
|
|
$paramNewGPO = @{
|
|
Name = $PolicyName
|
|
Comment = $PolicyComment
|
|
ErrorAction = Stop
|
|
WarningAction = SilentlyContinue
|
|
Confirm = $false
|
|
}
|
|
|
|
$null = (New-GPO @paramNewGPO)
|
|
|
|
Write-Verbose -Message ('Created {0}' -f $PolicyName)
|
|
}
|
|
catch
|
|
{
|
|
Write-Verbose -Message ('The Policy {0} exists' -f $PolicyName)
|
|
}
|
|
|
|
#endregion CreateGroupPolicy
|
|
|
|
#region ModifyGroupPolicy
|
|
|
|
try
|
|
{
|
|
Write-Verbose -Message ('Try to modify {0}' -f $PolicyName)
|
|
|
|
$null = ((Get-GPO -Name $PolicyName).GpoStatus = $UserSettingsDisabled)
|
|
|
|
Write-Verbose -Message ('Modified {0}' -f $PolicyName)
|
|
}
|
|
catch
|
|
{
|
|
Write-Error -Message ('Unable to modify {0}' -f $PolicyName) -ErrorAction $STP
|
|
|
|
# We are done here...
|
|
break
|
|
}
|
|
|
|
#endregion ModifyGroupPolicy
|
|
|
|
#region ServicesTcpipQoSName
|
|
|
|
try
|
|
{
|
|
Write-Verbose -Message ('Try to Set {0} to {1} {2} in {3}' -f $ServicesTcpipQoSName, $ServicesTcpipQoSValue, $One, $PolicyName)
|
|
|
|
# Cleanup
|
|
$paramSetGPPrefRegistryValue = $null
|
|
|
|
# Splat reusable parameters
|
|
$paramSetGPPrefRegistryValue = @{
|
|
Name = $PolicyName
|
|
ErrorAction = Stop
|
|
WarningAction = SilentlyContinue
|
|
Context = $Context
|
|
Key = $ServicesTcpipQoSName
|
|
ValueName = $ServicesTcpipQoSValue
|
|
Value = $One
|
|
Type = $STRG
|
|
Action = $Action
|
|
}
|
|
|
|
$null = (Set-GPPrefRegistryValue @paramSetGPPrefRegistryValue)
|
|
|
|
Write-Verbose -Message ('Set {0} to {1} {2} in {3}' -f $ServicesTcpipQoSName, $ServicesTcpipQoSValue, $One, $PolicyName)
|
|
}
|
|
catch
|
|
{
|
|
Write-Warning -Message ('Unable to Set {0} to {1} {2} in {3}' -f $ServicesTcpipQoSName, $ServicesTcpipQoSValue, $One, $PolicyName)
|
|
}
|
|
|
|
#endregion ServicesTcpipQoSName
|
|
|
|
#region EdgeToExchangeAudio
|
|
|
|
try
|
|
{
|
|
Write-Verbose -Message ('Try to set Edge to Exchange UM Audio QoS in {0}' -f $PolicyName)
|
|
|
|
# Cleanup
|
|
$paramSetGPRegistryValue = $null
|
|
|
|
# Splat reusable parameters
|
|
$paramSetGPRegistryValue = @{
|
|
Name = $PolicyName
|
|
ErrorAction = $STP
|
|
WarningAction = $SC
|
|
Confirm = $false
|
|
Key = 'HKLM\SOFTWARE\Policies\Microsoft\Windows\QoS\Edge to Exchange UM Audio QoS'
|
|
ValueName = $Version, $AppName, $Protocol, $LocPort, $LocIP, $LocIPLen, $RemPort, $RemIP, $RemIPLen, $DscpVal, $ThrotRate
|
|
Type = $STRG
|
|
Value = $OneZero, $WC, $WC, '1024:65535', $WC, $WC, $WC, $WC, $WC, $AudioMark, $MinusOne
|
|
}
|
|
|
|
$null = (Set-GPRegistryValue @paramSetGPRegistryValue)
|
|
|
|
Write-Verbose -Message ('Set Edge to Exchange UM Audio QoS in {0}' -f $PolicyName)
|
|
}
|
|
catch
|
|
{
|
|
Write-Warning -Message ('Unable to set Edge to Exchange UM Audio QoS in {0}' -f $PolicyName)
|
|
}
|
|
|
|
#endregion EdgeToExchangeAudio
|
|
|
|
#region umservices_exe
|
|
|
|
try
|
|
{
|
|
Write-Verbose -Message ('Try to set Exchange UM Audio to Edge QoS - umservices.exe in {0}' -f $PolicyName)
|
|
|
|
# Cleanup
|
|
$paramSetGPRegistryValue = $null
|
|
|
|
# Splat reusable parameters
|
|
$paramSetGPRegistryValue = @{
|
|
Name = $PolicyName
|
|
ErrorAction = $STP
|
|
WarningAction = $SC
|
|
Confirm = $false
|
|
Key = 'HKLM\SOFTWARE\Policies\Microsoft\Windows\QoS\Exchange UM Audio to Edge QoS - umservices.exe'
|
|
ValueName = $Version, $AppName, $Protocol, $LocPort, $LocIP, $LocIPLen, $RemPort, $RemIP, $RemIPLen, $DscpVal, $ThrotRate
|
|
Type = $STRG
|
|
Value = $OneZero, 'umservices.exe', $WC, '', $WC, $WC, $WC, $WC, $WC, $AudioMark, $MinusOne
|
|
}
|
|
|
|
$null = (Set-GPRegistryValue @paramSetGPRegistryValue)
|
|
|
|
Write-Verbose -Message ('Set Exchange UM Audio to Edge QoS - umservices.exe in {0}' -f $PolicyName)
|
|
}
|
|
catch
|
|
{
|
|
Write-Warning -Message ('Unable to set Exchange UM Audio to Edge QoS - umservices.exe in {0}' -f $PolicyName)
|
|
}
|
|
|
|
#endregion umservices_exe
|
|
|
|
#region Microsoft_Exchange_UM_CallRouter_exe
|
|
|
|
try
|
|
{
|
|
Write-Verbose -Message ('Try to set Exchange UM Audio to Edge QoS - Microsoft.Exchange.UM.CallRouter.exe in {0}' -f $PolicyName)
|
|
|
|
# Cleanup
|
|
$paramSetGPRegistryValue = $null
|
|
|
|
# Splat reusable parameters
|
|
$paramSetGPRegistryValue = @{
|
|
Name = $PolicyName
|
|
ErrorAction = $STP
|
|
WarningAction = $SC
|
|
Confirm = $false
|
|
Key = 'HKLM\SOFTWARE\Policies\Microsoft\Windows\QoS\Exchange UM Audio to Edge QoS - Microsoft.Exchange.UM.CallRouter.exe'
|
|
ValueName = $Version, $AppName, $Protocol, $LocPort, $LocIP, $LocIPLen, $RemPort, $RemIP, $RemIPLen, $DscpVal, $ThrotRate
|
|
Type = $STRG
|
|
Value = $OneZero, 'Microsoft.Exchange.UM.CallRouter.exe', $WC, '', $WC, $WC, $WC, $WC, $WC, $AudioMark, $MinusOne
|
|
}
|
|
|
|
$null = (Set-GPRegistryValue @paramSetGPRegistryValue)
|
|
|
|
Write-Verbose -Message ('Set Exchange UM Audio to Edge QoS - Microsoft.Exchange.UM.CallRouter.exe in {0}' -f $PolicyName)
|
|
}
|
|
catch
|
|
{
|
|
Write-Warning -Message ('Unable to set Exchange UM Audio to Edge QoS - Microsoft.Exchange.UM.CallRouter.exe in {0}' -f $PolicyName)
|
|
}
|
|
|
|
#endregion Microsoft_Exchange_UM_CallRouter_exe
|
|
|
|
#region umworkerprocess_exe
|
|
|
|
try
|
|
{
|
|
Write-Verbose -Message ('Try to set Exchange UM Audio to Edge QoS - umworkerprocess.exe in {0}' -f $PolicyName)
|
|
|
|
# Cleanup
|
|
$paramSetGPRegistryValue = $null
|
|
|
|
# Splat reusable parameters
|
|
$paramSetGPRegistryValue = @{
|
|
Name = $PolicyName
|
|
ErrorAction = $STP
|
|
WarningAction = $SC
|
|
Confirm = $false
|
|
Key = 'HKLM\SOFTWARE\Policies\Microsoft\Windows\QoS\Exchange UM Audio to Edge QoS - umworkerprocess.exe'
|
|
ValueName = $Version, $AppName, $Protocol, $LocPort, $LocIP, $LocIPLen, $RemPort, $RemIP, $RemIPLen, $DscpVal, $ThrotRate
|
|
Type = $STRG
|
|
Value = $OneZero, 'umworkerprocess.exe', $WC, '', $WC, $WC, $WC, $WC, $WC, $AudioMark, $MinusOne
|
|
}
|
|
|
|
$null = (Set-GPRegistryValue @paramSetGPRegistryValue)
|
|
|
|
Write-Verbose -Message ('Set Exchange UM Audio to Edge QoS - umworkerprocess.exe in {0}' -f $PolicyName)
|
|
}
|
|
catch
|
|
{
|
|
Write-Warning -Message ('Unable to set Exchange UM Audio to Edge QoS - umworkerprocess.exe in {0}' -f $PolicyName)
|
|
}
|
|
|
|
#endregion umworkerprocess_exe
|
|
}
|
|
|
|
END
|
|
{
|
|
Write-Output -InputObject ('Done with the creation of {0}' -f $PolicyName)
|
|
}
|
|
|
|
#region License
|
|
|
|
<#
|
|
Copyright (c) 2017, Joerg Hochwald. All rights reserved.
|
|
|
|
Redistribution and use in source and binary forms, with or without
|
|
modification, are permitted provided that the following conditions are met:
|
|
* Redistributions of source code must retain the above copyright notice, this
|
|
list of conditions and the following disclaimer.
|
|
* Redistributions in binary form must reproduce the above copyright notice,
|
|
this list of conditions and the following disclaimer in the documentation
|
|
and/or other materials provided with the distribution.
|
|
* Neither the name of the copyright holder nor the names of its
|
|
contributors may be used to endorse or promote products derived from
|
|
this software without specific prior written permission.
|
|
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
By using the Software, you agree to the License, Terms and Conditions above!
|
|
#>
|
|
|
|
<#
|
|
This is a third-party Software!
|
|
|
|
The developer of this Software is NOT sponsored by or affiliated with Microsoft Corp (MSFT) or any of its subsidiaries in any way
|
|
The Software is not supported by Microsoft Corp (MSFT)!
|
|
#>
|
|
|
|
#endregion License
|