?
Solved

WMI Win32_UserAccount Returning Domain Users Instead of Local

Posted on 2013-05-20
5
Medium Priority
?
3,030 Views
Last Modified: 2013-05-20
I have a situation where, running the WMI Query "Select * from Win32_UserAccount" returns all of the domain users when connected to any desktop in the domain.

How can I modify the query to return only the local users for that machine?
0
Comment
Question by:cefranklin
  • 2
  • 2
5 Comments
 
LVL 42

Expert Comment

by:Meir Rivkin
ID: 39181702
Returns a list of all the user accounts found on the local computer.
Set objNetwork = CreateObject("Wscript.Network")
strComputer = objNetwork.ComputerName
Set colAccounts = GetObject("WinNT://" & strComputer & "")
colAccounts.Filter = Array("user")
For Each objUser In colAccounts
    Wscript.Echo objUser.Name
Next
0
 
LVL 42

Expert Comment

by:Meir Rivkin
ID: 39181705
0
 
LVL 2

Author Comment

by:cefranklin
ID: 39181716
Sorry, this code works but, looking specifically for WMI
0
 
LVL 71

Accepted Solution

by:
Qlemo earned 2000 total points
ID: 39181718
Look at the example in http://msdn.microsoft.com/en-us/library/windows/desktop/aa394507(v=vs.85).aspx - just provide the computer name as domain name (and no username) to restrict to local accounts. E.g. as WQL:
select * from Win32_UserAccount where Domain = 'TheComputer'

Open in new window

0
 
LVL 2

Author Closing Comment

by:cefranklin
ID: 39181734
Restriciting by domain to the local pc works. Thank you.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
When you discover the power of the R programming language, you are going to wonder how you ever lived without it! Learn why the language merits a place in your programming arsenal.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Loops Section Overview
Suggested Courses
Course of the Month15 days, 12 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question