Link to home
Create AccountLog in
Avatar of cefranklin
cefranklinFlag for United States of America

asked on

WMI Win32_UserAccount Returning Domain Users Instead of Local

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?
Avatar of Meir Rivkin
Meir Rivkin
Flag of Israel image

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
Avatar of cefranklin


Sorry, this code works but, looking specifically for WMI
Avatar of Qlemo
Flag of Germany image

Link to home
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Restriciting by domain to the local pc works. Thank you.