Tech Support Guy banner
Status
Not open for further replies.

BATCH Store WMI Query with multiple conditions into variable

3K views 2 replies 3 participants last post by  djjarvis 
#1 ·
Hi All

I am using this line in a batch script which successfully stores a user's SID value into a variable called SID

Code:
FOR /F "tokens=1,2 delims==" %%s IN ('wmic path win32_useraccount where name^='%_curruser%' get sid /value ^| find /i "SID"') DO SET SID=%%t
I'd like to modify this to include an "AND" in the WMI Query but I can't seem to get it to work.

The correct query is:

Code:
wmic path win32_useraccount where "name='%USERNAME%' and Domain like 'HB%'" GET SID /VALUE
Can someone please help me translate this so the SID value is stored into a variable?

Thanks!!!!!
 
Status
Not open for further replies.
You have insufficient privileges to reply here.
Top