Skip to content

Instantly share code, notes, and snippets.

@itpropro
Created March 19, 2016 18:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save itpropro/5625c5171329904460b1 to your computer and use it in GitHub Desktop.
Save itpropro/5625c5171329904460b1 to your computer and use it in GitHub Desktop.
function Get-SidfromHex {
param
(
[string]$Sid
)
$ByteSid = New-Object Byte[] 150
for ($i = 0; $i -lt $Sid.Length ; $i += 2) {
$ByteSid.Set(($i/2),([Byte]::Parse($Sid.Substring($i, 2), [System.Globalization.NumberStyles]::HexNumber)))
}
New-Object System.Security.Principal.SecurityIdentifier($ByteSid,0)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment