wmi commands in windows powershell

WMI stores information of the system in Win32 classes. Here is the list of some of the classes. Each of below classes has methods and properties defined by Microsoft.
  • Win32_Desktop
  • Win32_Environment
  • Win32_TimeZone
  • Win32_Directory
  • Win32_LogicalDisk
  • Win32_ComputerSystem
  • Win32_OperatingSystem
  • Win32_SystemProcesses
  • Win32_SystemServices
  • Win32_SystemUsers
  • Win32_Process
  • Win32_Service
  • Win32_ProcessStartup
  • Win32_Registry
  • Win32_ScheduledJob
  • Win32_Account
  • Win32_Group
  • Win32_LogonSession
  • Win32_SystemAccount
  • Win32_UserAccount
Here are some of the WMI methods you can execute and get information from above classes. Below command will display the list of all user accounts in the system.
 
> Get-WmiObject -Query “SELECT * FROM Win32_UserAccount”

Below command will display the list of all hard drives in the systems.
 
> Get-WmiObject -Query “SELECT * FROM Win32_LogicalDisk”

Below command will get all processes with name “chrome” and then invoke “Terminate” method on each process.
 
Get-WmiObject -Class Win32_Process -Filter  “name=’chrome.exe'”| 
Invoke-WmiMethod -Name Terminate

Web development and Automation testing

solutions delivered!!