Show All Properties of a PowerShell Object
Get-WmiObjectto Show All Properties of a PowerShell Object
- Retrieve the Class Instance/Object Information
Format-ListCmdlet to Display Properties
There are requirements to find information about the Windows machine and its components such as network, application, and services. The Common Information Model (CIM) is an open-source standard for manipulating these components and their information.
Microsoft has implemented its standard on top of CIM called Windows Management Instrumentation (WMI) to query and manipulate computer, service, and network information.
Get-WmiObject to Show All Properties of a PowerShell Object
Get-WmiObject cmdlet can be used to request information from the WMI repository. Also, it enables you to work with remote systems as well.
Hence, the Windows system management process becomes a lot easier. Let’s check the available classes using the
This command will output all the classes available in the default namespace of your local machine. The default namespace is
ROOT\cimv2 in the Windows computer.
It is possible to specify a different namespace other than the default one (
ROOT\cimv2). We can use the
-Namespace parameter to change the default namespace.
Get-WmiObject -Namespace <custom_namespace>
Retrieve the Class Instance/Object Information
There are hundreds of WMI classes available to use. We can retrieve the information for a given class as shown in the following.
Get-WmiObject -Class Win32_computersystem
Here, we are retrieving information for the
Win32_computersystem class. It returns the
Win32_computersystem object with its properties as shown in the following.
There are a limited number of properties shown in the output. The
Win32_computersystem object contains more properties than these.
We can use the
Format-List cmdlet to display all the properties of a retrieved object.
Format-List Cmdlet to Display Properties
Format-List can be piped with the output of another command to format the results. This cmdlet can display the specified or all the properties of a retrieved WMI object.
Let’s specify some properties for the
Get-WmiObject -Class Win32_computersystem | Format-List -Property Name, Model, Manufacturer
Get-WmiObject returns the default properties for the
Win32_computersystem object. Then the output will be passed through the pipeline operator(
|) to the
We can pass the
-Property parameter to the
Format-List cmdlet. That will filter out the final output with the given three properties.
Sometimes, it is important to check all the properties and values available for a specified WMI object. In that case, you need to use
-Property * to retrieve all the available properties and their values.
* indicates all properties.
Get-WmiObject -Class Win32_computersystem | Format-List -Property *
The output contains all the properties and the values available for the
Win32_computersystem object. We can omit the
-Property parameter in the above command and write it.
Get-WmiObject -Class Win32_computersystem | Format-List *
The above command should display the same output as above.
Related Article - PowerShell Object
- Nested ForEach-Object and Where-Object in PowerShell
- PowerShell Sort Object
- Filter and Isolate PowerShell Objects
- Determine if Two Objects Are Identical in PowerShell
- Counting Objects in PowerShell