# Here is a quick script for getting a user's SID.
# I borrowed the function and added some usability code
# Enjoy :-)
# User input to set the username variable
Write-Host "This script will identify the SID of a username"
$User = Read-Host "What username do you want converted?"
# The function to get the SID & output that value in yellow
function Name2SID($name, $domain=$env:userdomain) {
$objUser = New-Object System.Security.Principal.NTAccount($domain,$name)
$strSID = $objUser.Translate([System.Security.Principal.SecurityIdentifier])
Write-Host "The SID for $User is: " -NoNewline; Write-Host $strSID.Value -ForegroundColor "Yellow"
}
# Call function with previously entered username parameter
Name2SID $User
No comments:
Post a Comment