- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to get the disabled local user accounts using PowerShell?
To get the disabled local user accounts using PowerShell on the local and the remote system, we can use the WMI or the CIM instance method with the Win32_UserAccount class and the Disabled property to filter the result.
PS C:\> gwmi win32_useraccount | where{$_.Disabled -eq $true}
You can filter out the properties using the specific properties use the Select-Object pipeline command.
PS C:\> gwmi win32_useraccount | where{$_.Disabled -eq $true} | Select Name, FullName, Caption
You can also use the CIM instance method alternatively,
PS C:\> Get-CimInstance win32_useraccount | where{$_.Disabled -eq $true}
To get the disabled accounts on the remote systems, use the -ComputerName parameter in the gwmi or the CIM instance command.
PS C:\> gwmi win32_useraccount -ComputerName Machine1, Machine2 | where{$_.Disabled -eq $true}
The above command will get the disabled local user accounts from the remote machines Machine1 and Machine2.
Advertisements