Skip to content

Instantly share code, notes, and snippets.

@JamesConlan96
Last active August 15, 2023 11:22
Show Gist options
  • Save JamesConlan96/c0dc94e8f6993b94c5c278c0e97a407b to your computer and use it in GitHub Desktop.
Save JamesConlan96/c0dc94e8f6993b94c5c278c0e97a407b to your computer and use it in GitHub Desktop.
A script to convert Windows SIDs to names
<#
.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