Last active
August 15, 2023 11:22
-
-
Save JamesConlan96/c0dc94e8f6993b94c5c278c0e97a407b to your computer and use it in GitHub Desktop.
A script to convert Windows SIDs to names
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
<# | |
.SYNOPSIS | |
A script to convert SIDs to names | |
.Description | |
A script to convert SIDs to names | |
.PARAMETER inFile | |
A file containing SIDs (1 per line) | |
#> | |
param ( | |
[Parameter(Mandatory=$true)][ValidateScript({ | |
if( -Not ($_ | Test-Path) ){ | |
throw "Specified input file does not exist" | |
} | |
return $true | |
})][System.IO.FileInfo]$inFile | |
) | |
Get-Content $inFile | ForEach-Object { | |
$SID = New-Object System.Security.Principal.SecurityIdentifier($_) | |
$objName = $SID.Translate([System.Security.Principal.NTAccount]) | |
$objName.Value | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment