Get-WmiObject

Get WMI class information, instances of classes or available classes.

Syntax
      Get-WmiObject [-namespace string]
         [-computerName string[]]
            [-credential PSCredential] [-list] [CommonParameters]

      Get-WmiObject [-class] string [[-property] string[]] [-namespace string]
          [-computerName string[]] [-filter string]
             [-credential PSCredential] [CommonParameters]

      Get-WmiObject -query string [-namespace string]
          [-computerName string[]]
             [-credential PSCredential] [CommonParameters]

Key
   -class 
       The name of a WMI class.

   -property
       A WMI class property (or set of properties) to retrieve.

   -namespace string
       The WMI repository namespace.

   -list 
       List the names of the WMI classes.
       If you don't specify the -Namespace parameter, then root\CIMV2 
       will be used by default.

   -computerName string[]
       The computer(s) to run against.
       A NETBIOS name, an IP address, full domain name or local (.)
       WMI information is retrieved via the WMI Service (CIMOM)
       on the specified computers.

   -filter string
       A where clause to use as a filter. Use the syntax of the WQL language.
       Do not include the WHERE keyword.
	   
   -query string
       A WMI Query Language (WQL) statement to run. 
       Event queries are not supported.

   -credential PSCredential
       Use the specified credential to authenticate the user. Type a user name  
       or submit a credential object (created with Get-Credential)
       If you supply a user name, you will be prompted for a password.

CommonParameters:
       -Verbose, -Debug, -ErrorAction, -ErrorVariable, -OutVariable.

For WMI to work against a remote machine you may need to first configure it's local Windows firewall to allow the remote access.

Examples

Display information about all processes:

PS C:\>get-wmiobject win32_process

Display information about all processes running on the machine 'Server64':

PS C:\>get-wmiobject win32_service -computername Server64

As above but passing credentials:

PS C:\>get-wmiobject win32_service -credential SS64\Simon -computer Server64

Display information about the Alerter service:

PS C:\>get-wmiobject -query "select * from win32_service where name='alerter'"

Stop the Alerter service:

PS C:\>(get-wmiobject win32_service -filter "name='alerter'").StopService()

Display all WMI classes in the root/default namespace:

PS C:\>get-wmiobject -namespace "root/default" -list

Display BIOS and Memory information:

PS C:\>get-wmiobject win32_bios | format-list *
PS C:\>get-wmiobject Win32_ComputerSystem
PS C:\>get-wmiobject Win32_PhysicalMemory

"A good question is like a miniskirt. Long enough to cover the essentials, but short enough to keep everyone interested" - Charles Halsey

Related Powershell Commands:

Get-WmiObject Win32_OperatingSystem - Get the OS and service pack
Get-Credential - Get a security credential object based on a user name and password.



Back to the Top

Simon Sheppard
SS64.com