Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


WMI Win32_UserAccount Returning Domain Users Instead of Local

Posted on 2013-05-20
Medium Priority
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?
Question by:cefranklin
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
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
LVL 42

Expert Comment

by:Meir Rivkin
ID: 39181705

Author Comment

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

Accepted Solution

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


Author Closing Comment

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

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying 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

In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
The Windows functions GetTickCount and timeGetTime retrieve the number of milliseconds since the system was started. However, the value is stored in a DWORD, which means that it wraps around to zero every 49.7 days. This article shows how to solve t…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
Suggested Courses

650 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