Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save ImperatorRuscal/b0f554be82fc9abdac2d4480692b0f66 to your computer and use it in GitHub Desktop.

Select an option

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
[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