Created
May 7, 2015 00:21
-
-
Save dlwyatt/370cbd42521d08db8652 to your computer and use it in GitHub Desktop.
Parse CSVDE-style SID string
This file contains 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
$funky = '010500000000000515000000AA7045F3F11474788C4A5F8AE9030000' | |
try | |
{ | |
$bytes = [byte[]]@( | |
for ($i = 0; $i -lt $funky.Length - 1; $i += 2) | |
{ | |
[byte]::Parse($funky.Substring($i, 2), [System.Globalization.NumberStyles]::AllowHexSpecifier) | |
} | |
) | |
$sid = New-Object System.Security.Principal.SecurityIdentifier($bytes, 0) | |
$sid.Value | |
} | |
catch | |
{ | |
throw "String '$funky' is garbage." | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment