Share via


Check if a local user account is disabled... on a remote computer

Question

Wednesday, September 19, 2012 9:32 PM

I have a list of servers that I need to check if the local guest account is enabled and show the output.  I'd rather not RDP into each machine and print a screenshot, but can use Powershell or CMD's "net user" command... or even Quest Power Tools... however I haven't found a way to query a local user other than writing C# code.

Is there an easier way of doing this?

All replies (3)

Thursday, September 20, 2012 3:41 AM ✅Answered

psexec + cmd line should suffice.  Pipe the results to a text file or however you prefer to 'display' them.

http://technet.microsoft.com/en-us/sysinternals/bb897553.aspx

psexec \\ServerName cmd /c net user yada yada

Otherwise, a remote PS session in powershell can do the same trick.

Don't forget to mark your posts as answered so they drop off the unanswered post filter. If I've helped you and you want to show your gratitude, just click that green thingy.


Thursday, September 20, 2012 5:17 AM ✅Answered

Hi,

Thanks for your post.

With PowerShell 2.0/3.0, you can run the following command to directly list the state of all local users.

Get-WmiObject -Class Win32_UserAccount -Filter "LocalAccount='$true'"|Select-Object Name,Disabled|Format-Table -AutoSize

As the Knuckle motioned, we need to start interactive session with remote computer first by using Enter-PSSession cmdlet. For more detailed information, please refer to the following article. Hope it helps.

Use PowerShell to Run WMI Commands on Remote Computers

http://blogs.technet.com/b/heyscriptingguy/archive/2012/07/09/use-powershell-to-run-wmi-commands-on-remote-computers.aspx

Running Remote Commands

http://technet.microsoft.com/en-us/library/dd819505.aspx

Best Regards,

Aiden

TechNet Subscriber Support

If you are TechNet Subscription user and have any feedback on our support quality, please send your feedback here.

Aiden Cao

TechNet Community Support


Monday, September 24, 2012 2:10 AM

Hi,

How are things going? I just want to check if the information provided was helpful. If there is any update or concern, please feel free to let us know.

Best Regards,
Aiden

TechNet Subscriber Support

If you are TechNet Subscription user and have any feedback on our support quality, please send your feedback here.

Aiden Cao

TechNet Community Support