Solved

WMI Win32_UserAccount Returning Domain Users Instead of Local

Posted on 2013-05-20
5
2,433 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:sedgwick
Comment Utility
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
Comment Utility
0
 
LVL 2

Author Comment

by:cefranklin
Comment Utility
Sorry, this code works but, looking specifically for WMI
0
 
LVL 68

Accepted Solution

by:
Qlemo earned 500 total points
Comment Utility
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
Comment Utility
Restriciting by domain to the local pc works. Thank you.
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
python question 5 56
exchange, scripts 3 46
Recursive folder search vbscript 7 28
Turning python script into an applet 12 29
Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
When you upgrade from Windows 8 to 8.1 or to Windows 10 or if you are like me you are on the Insider Program you may find yourself with many 450MB recovery partitions.  With a traditional disk that may not be a problem but with relatively smaller SS…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Windows 8 came with a dramatically different user interface known as Metro. Notably missing from that interface was a Start button and Start Menu. Microsoft responded to negative user feedback of the Metro interface, bringing back the Start button a…

728 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now