Solved

WMI Win32_UserAccount Returning Domain Users Instead of Local

Posted on 2013-05-20
5
2,695 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
[X]
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
5 Comments
 
LVL 42

Expert Comment

by:sedgwick
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:sedgwick
ID: 39181705
0
 
LVL 2

Author Comment

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

Accepted Solution

by:
Qlemo earned 500 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

Turn Insights Into Action

You’ve already invested in ITSM tools, chat applications, automation utilities, and more. Fortify these solutions with intelligent communications so you can drive business processes forward.

With xMatters, you'll never miss a beat.

Question has a verified solution.

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

This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
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…
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

695 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