Created
February 16, 2016 17:21
-
-
Save Dan1el42/ddd05775467c9ec16cfe to your computer and use it in GitHub Desktop.
MS-RDG-Device-Redirection - Get decimal value for configuration
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
| # MS-RDG-Device-Redirection | |
| # https://msdn.microsoft.com/en-us/library/cc243459.aspx | |
| $ByteArray = [System.Array]::CreateInstance([byte], 32) | |
| $ByteArray.Set(0, 1) # Drive redirection disabled | |
| $ByteArray.Set(1, 1) # Printers redirection disabled | |
| $ByteArray.Set(2, 1) # Serial ports redirection disabled | |
| $ByteArray.Set(3, 1) # Clipboard redirection disabled | |
| $ByteArray.Set(4, 0) # Plug and play devices redirection enabled | |
| $ByteArray.Set(29, 0) # Device redirection is controlled by bits 0..4 | |
| $ByteArray.Set(30, 0) # Device redirection is controlled, first, by bit 29 and then by bits 0..4 | |
| Write-Output ([System.BitConverter]::ToInt32($ByteArray, 0)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You have a slight problem here in that you are working on a 32-byte array instead of a 32-bit one. You really want something more like this.
Note:: I'm forcing it to an unsigned 64 bit integer so you can drag the binary out of it if you wanted (and to avoid PS's propensity to take undeclared numeric types as doubles and give the output in scientific notation).
Just uncomment the lines you want to activate in the policy. This will give you the proper decimal value (where setting per-byte won't)