1- JSI Tip 5345. How can I get a user's SID in a batch file?

Using the public domain GETSID.EXE, I have scripted UserSID.bat. The syntax for using UserSID.bat is:

call usersid \\computername UserName


\\ComputerName is either a domain controller, if you want the domain SID, or the local workstation, if the UserName is local.

UserName is the User Account whose SID you want.

UserSID.bat returns the SID in the sid environment variable, %sid%.

NOTE: UserSID.bat will NOT work if the UserName contains spaces.

UserSID.bat contains:

@echo off
set sid=
If {%2}=={} goto syntax
if not exist %1\c$ goto syntax
for /f "Skip=2 Tokens=7" %%i in ('getsid %1 %2 %1 %2') do set sid=%%i
goto :EOF
@echo Syntax call UserSID \\DC_or_Local UserName

2- Handy VBS script :

Dim UName
UName = InputBox("Enter The User Name :","Username To SID","E0")

strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Set objAccount = objWMIService.Get _
    ("Win32_UserAccount.Name='" & UName & "',Domain='DOMAIN NETBIOS NAME'")
Wscript.Echo objAccount.SID

Ad blocker interference detected!

Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.