How to get a server’s machine SID

Anonymous KH
Anonymous KH used Ask the Experts™
What is the WMIC command to get the Server/machine SID, not the domain SID?

I keep reading how to get useracoount SID or using Powershell.

What I require is using WMIC command only.
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
dsquery * -Filter "(name=MyComputer)" -attr objectSID


dsquery computer -name "MyComputer" | dsget computer -SID

all the best
Most Valuable Expert 2018
Distinguished Expert 2018
You query for the local user account SID ending with -500 (default administrator), and get rid of the -500; that's the local computer SID.
Plain wmic query returning the local Administrator's SID:
wmic.exe useraccount WHERE "(Sid LIKE '%%-500') AND (Domain='%ComputerName%')" GET Sid /value

Open in new window

Batch script returning the computer's SID:
@echo off
for /f "delims=" %%a in ('wmic.exe useraccount WHERE "(Sid LIKE '%%-500') AND (Domain='%ComputerName%')" GET Sid /value') do (for /f "delims=" %%b in ("%%a") do set %%b)
set ComputerSid=%SID:~0,-4%
echo %ComputerSid%

Open in new window

Neil PettyICT Contractor
You may find the freeware tool WMI Explorer useful :

It has examples of WMI lookups VBScript, Powershell
Qlemo"Batchelor", Developer and EE Topic Advisor
Top Expert 2015
Note: oBdA's comment is correct, as long as you are running it on the machine to check. For remote execution, we would need significantly more effort, but that is probably out of scope of this question.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial