PoshCode Logo PowerShell Code Repository

Difference between
modified post 6847 by Basant on Tue 18th Apr 09:12 and
original post 6838 by S-1-5-21-2025429 on Wed 12th Apr 13:02
Showold version | new version | both versions

    
11
# Ported from C# technique found here: http://forums.asp.net/p/1298956/2529558.aspx
22
param ( [string]$SidString )
44
# Create SID .NET object using SID string provided
55
$sid = New-Object system.Security.Principal.SecurityIdentifier $sidstring
77
# Create a byte array of the proper length
88
$sidBytes = New-Object byte[] $sid.BinaryLength
1010
#Convert to bytes
1111
$sid.GetBinaryForm( $sidBytes, 0 )
1313
# Iterate through bytes, converting each to the hexidecimal equivalent
1414
$hexArr = $sidBytes | ForEach-Object { $_.ToString("X2") }
1616
# Join the hex array into a single string for output
1717
$hexArr -join ''

ContributeMost Recent Contributions (feed)

Contribute ... Next Page