Reputation: 21
the result is blank. is there any solution to make it show
https://i.sstatic.net/a5lGz.png
Upvotes: 2
Views: 7111
Reputation: 27526
For getting a specific name, query the domain too, otherwise it's slow if the user (including System) running wmic is on active directory. The class is indexed this way. (Running from cmd.)
wmic UserAccount where "Name='admin' and domain='%computername%'" get name
Name
admin
Bonus powershell version (67 seconds without the domain and with localaccount):
Get-WmiObject Win32_UserAccount -Filter "name = 'admin' and
domain = '$env:computername'"
AccountType : 512
Caption : MYCOMP\admin
Domain : MYCOMP
SID : S-1-5-21-3961843709-2576926490-2001110831-1101
FullName :
Name : admin
Upvotes: 1
Reputation: 27
I struggled with the same. That the execution of wmic takes too long. Solution is simple, be more specific.
CMD-Before:
wmic UserAccount where Name="admin" set PasswordExpires=False
CMD-After:
wmic path Win32_UserAccount where "Name='admin' and LocalAccount=True" set PasswordExpires=False
Upvotes: 1
Reputation: 336
When a system is joined to a domain, the default functionality of "wmic useraccount" is to enum all users in the domain. For even medium sized domains, it's not good at doing this. This query can be filtered / limited to a single system with a "where" clause:
wmic.exe useraccount where "localaccount=true" get name,sid,disabled
Disabled Name SID
TRUE Administrator S-1-5-21-27797481-235746463-772742770-500
FALSE Me-Admin S-1-5-21-27797481-235746463-772742770-1001
FALSE Me-NonAdmin S-1-5-21-27797481-235746463-772742770-1002
TRUE DefaultAccount S-1-5-21-27797481-235746463-772742770-503
TRUE Guest S-1-5-21-27797481-235746463-772742770-501
FALSE ToolBox S-1-5-21-27797481-235746463-772742770-1007
TRUE WDAGUtilityAccount S-1-5-21-27797481-235746463-772742770-504
Upvotes: 3