-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy path1071.ps1
More file actions
45 lines (37 loc) · 1.1 KB
/
1071.ps1
File metadata and controls
45 lines (37 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
function Convert-StringSID {
<#
.Synopsis
Takes a SID string and outputs a Win32_SID object.
.Parameter sidstring
The SID in SDDL format. Example: S-1-5-21-39260824-743453154-142223018-195717
.Description
Takes a SID string and outputs a Win32_SID object.
Note: it also adds an extra property, base64_sid, the base64 representation
of the binary SID.
.Example
PS> Convert-StringSID 'S-1-5-21-39260824-743453154-142223018-195717'
.Example
PS> $list_of_sids |
Convert-StringSID |
%{Write-Output "$($_.ReferenceDomainName)\$($_.AccountName)"}
MYDOMAIN\somename
MYDOMAIN\anotheraccount
.Notes
NAME: Convert-Base64SID
AUTHOR: tojo2000
#Requires -Version 2.0
#>
param([Parameter(Position = 0,
Mandatory = $true,
@@ ValueFromPipeline = $true]
[string]$sidstring)
BEGIN {}
@@ PROCESS{
[wmi]$obj = 'Win32_SID.SID="{0}"' -f $sidstring
$encoded = [System.Convert]::ToBase64String($obj.BinaryRepresentation)
$obj |
Add-Member -MemberType NoteProperty -Name base64_sid -Value $encoded
Write-Output $obj
}
END{}
}