Last active
March 6, 2023 21:01
-
-
Save ImperatorRuscal/b0f554be82fc9abdac2d4480692b0f66 to your computer and use it in GitHub Desktop.
The value to use in NPS / RADIUS in order to set Remote Desktop Gateway redirection policy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [CmdletBinding()] | |
| Param( | |
| [Parameter(Mandatory=$false)] | |
| [switch]$DriveRedirectBlock, | |
| [Parameter(Mandatory=$false)] | |
| [switch]$PrinterRedirectBlock, | |
| [Parameter(Mandatory=$false)] | |
| [switch]$SerialPortRedirectBlock, | |
| [Parameter(Mandatory=$false)] | |
| [switch]$ClipboardRedirectBlock, | |
| [Parameter(Mandatory=$false)] | |
| [switch]$PlugAndPlayRedirectBlock, | |
| [Parameter(Mandatory=$false)] | |
| [switch]$OnlyAllowConnectionsThatEnforceBlocks | |
| ) | |
| [char[]]$bitfield = "00000000000000000000000000000000" | |
| function SetBit([int] $bit) | |
| { | |
| Write-Verbose "Setting Bit # $bit" | |
| $bitfield[($bitfield.Length - $bit)-1] = '1' | |
| } | |
| if($DriveRedirectBlock){SetBit 0} | |
| if($PrinterRedirectBlock){SetBit 1} | |
| if($SerialPortRedirectBlock){SetBit 2} | |
| if($ClipboardRedirectBlock){SetBit 3} | |
| if($PlugAndPlayRedirectBlock){SetBit 4} | |
| if($OnlyAllowConnectionsThatEnforceBlocks){SetBit 27} | |
| [string]$bitfield = -join $bitfield | |
| [int32]$bitfield = [System.Convert]::ToInt32($bitfield,2) | |
| Write-Host "Set the RADIUS Vendor-Specific Attribute of ""TSG-Device-Redirection"" to a value of $bitfield" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment