22 lines
487 B
PowerShell
22 lines
487 B
PowerShell
function Get-UsernameFromSid {
|
|
<#
|
|
.SYNOPSIS
|
|
Converts a SID to a Username
|
|
|
|
.PARAMETER SecurityIdentifier
|
|
Identifier to use to find a username
|
|
#>
|
|
|
|
[CmdletBinding()]
|
|
Param(
|
|
[Parameter(Mandatory = $true)]
|
|
[Alias("SID")]
|
|
[string]$SecurityIdentifier
|
|
)
|
|
|
|
$objSID = New-Object System.Security.Principal.SecurityIdentifier($SecurityIdentifier)
|
|
$objUser = $objSID.Translate([System.Security.Principal.NTAccount])
|
|
return $objUser.Value
|
|
}
|
|
|