Get-WmiObject

 

Additional Resources for Get-WmiObject

 

Retrieving Data Using WMI

http://www.microsoft.com/technet/scriptcenter/topics/msh/cmdlets/get-wmiobject.mspx

 

Accessing WMI From Windows PowerShell

http://www.microsoft.com/technet/scriptcenter/topics/msh/mshandwmi.mspx

 

Retrieving Multi-Valued WMI Properties from Windows PowerShell

http://www.microsoft.com/technet/scriptcenter/topics/msh/multivalued.mspx

 

 

SYNOPSIS

Gets instances of WMI classes or information about available classes.

 

SYNTAX

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

 

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

 

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

 

DETAILED DESCRIPTION

Gets instances of WMI classes or information about available classes. The ComputerName parameter can always be used to target a remote computer. If the List parameter is specified, the cmdlet gets information about the WMI classes available in a specified namespace. If the Query parameter is specified, the cmdlet runs a WMI query language (WQL) statement.

 

PARAMETERS

 

-class <string>

Specifies the name of a WMI class. When this parameter is used, the cmdlet retrieves instances of the WMI class.

 

Required?

true

Position?

1

Default value

 

Accept pipeline input?  

false

Accept wildcard characters? 

false

 

-property <string[]>

Specifies the WMI class property or set of properties to retrieve.

 

Required?

false

Position?

2

Default value

*

Accept pipeline input?  

false

Accept wildcard characters? 

false

 

-namespace <string>

When used with the Class parameter, this parameter specifies the WMI repository namespace where the referenced WMI class is located. When used with the List parameter, it specifies the namespace from which to gather WMI class information.

 

Required?

false

Position?

named

Default value

Root/cimv2

Accept pipeline input?  

false

Accept wildcard characters? 

false

 

-computerName <string[]>

Specifies the computer or computers the cmdlet will run against. The cmdlet will retrieve WMI class information and instances of WMI classes from the WMI Service (CIMOM) on the specified computers. The name of each computer can be specified as a NETBIOS name, an IP address, or a fully-qualified domain name. In addition, you can specify the local computer by using the dot (.) character.

 

Required?

false

Position?

named

Default value

localhost

Accept pipeline input?  

false

Accept wildcard characters? 

false

 

-filter <string>

Specifies a where clause to use as a filter. Use the syntax of the WQL language. Do not include the where keyword in the value of the parameter.

 

Required?

false

Position?

named

Default value

 

Accept pipeline input?  

false

Accept wildcard characters? 

false

 

-credential <PSCredential>

Uses the specified credential to authenticate the user. You can type a user name or submit a credential object created by using Get-Credential. If you supply a user name, you will be prompted for a password.

 

Required?

false

Position?

named

Default value

 

Accept pipeline input?  

false

Accept wildcard characters? 

false

 

-list <SwitchParameter>

Used to indicate that the names of the WMI classes in the WMI repository namespace specified in the Namespace parameter should be retrieved and displayed. The Default Namespace registry entry, contained in the registry key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WBEM\Scripting is not used by this cmdlet to determine the default namespace. If you specify the List parameter, but not the Namespace parameter, the root\CIMV2 namespace is used by default.

 

Required?

false

Position?

named

Default value

False

Accept pipeline input?  

false

Accept wildcard characters? 

false

 

-query <string>

Specifies a WMI Query Language (WQL) statement to run. Event queries are not supported.

 

Required?

true

Position?

named

Default value

 

Accept pipeline input?  

false

Accept wildcard characters? 

false

 

<CommonParameters>

This cmdlet supports the common parameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, and -OutVariable. For more information, type, "get-help about_commonparameters".

 

INPUT TYPE

None

 

NOTES

 

For more information, type "Get-Help Get-WmiObject -detailed". For technical information, type "Get-Help Get-WmiObject -full".

 

When specifying multiple values for a parameter, use commas to separate the values. For example, "<parameter-name> <value1>, <value2>".

 

To access WMI information on a remote computer, the cmdlet must run under an account that is a member of the local administrators group on the remote computer. Alternatively, the default access control on the WMI namespace of the remote repository can be changed to give other account access rights.

 

All the properties of a WMI class are not displayed by default. The set of properties that will be displayed for each WMI class is specified in the types.ps1xml configuration file. One of the examples included in this help topic demonstrates how to override this behavior by using the format-list cmdlet.

 

EXAMPLE 1

 

get-wmiobject win32_process

 

This command displays information about all of the processes running on a computer.

 

EXAMPLE 2

 

get-wmiobject win32_service -computername 127.0.0.1

 

This command displays information about the services on the local computer. It does so by specifying the IP address 127.0.0.1. This IP address can be changed to any other valid IP address on your network, enabling you to display information about the services on that remote computer. By default, the account you are running under must be a member of the local administrators group on the remote computer you specify for the command to succeed.

 

EXAMPLE 3

 

get-wmiobject -namespace "root/default" -list

 

This command displays the WMI classes in the root/default namespace of the local computer.

 

EXAMPLE 4

 

get-wmiobject -query "select * from win32_service where name='alerter'"

 

This command displays information about the Alerter service.

 

EXAMPLE 5

 

(get-wmiobject win32_service -filter "name='alerter'").StopService()

 

This command stops the Alerter service. It calls the StopService method of the win32_service WMI class.

 

EXAMPLE 6

 

get-wmiobject win32_bios | format-list *

 

This command displays BIOS information. It displays all of the properties of the WMI class, not just the ones specified in the types.ps1xml configuration file.

 

EXAMPLE 7

 

get-wmiobject win32_service -credential FABRIKAM\administrator -computer fabrikam

 

This command displays service information on a computer named fabrikam. It specifies a user account name by using the Credential parameter, which causes a dialog to be displayed to gather the corresponding password.

 

RELATED LINKS

Get-Credential