Show All Properties of a PowerShell Object

Migel Hewage Nimesha Jan 30, 2023 May 27, 2022
  1. Use Get-WmiObject to Show All Properties of a PowerShell Object
  2. Retrieve the Class Instance/Object Information
  3. Use Format-List Cmdlet to Display Properties
Show All Properties of a PowerShell Object

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.

Use Get-WmiObject to Show All Properties of a PowerShell Object

The 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 Get-WmiObject cmdlet.

Get-WmiObject -List

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.

Output:

Get-WmiObject

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.

Get-WmiObject -Class

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.

Use Format-List Cmdlet to Display Properties

The 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 Win32_computersystem instance.

Get-WmiObject -Class Win32_computersystem | Format-List -Property Name, Model, Manufacturer

Output:

Format-List

The Get-WmiObject returns the default properties for the Win32_computersystem object. Then the output will be passed through the pipeline operator(|) to the Format-List command.

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.

The * indicates all properties.

Get-WmiObject -Class Win32_computersystem | Format-List -Property *

Output:

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.

Migel Hewage Nimesha avatar Migel Hewage Nimesha avatar

Nimesha is a Full-stack Software Engineer for more than five years, he loves technology, as technology has the power to solve our many problems within just a minute. He have been contributing to various projects over the last 5+ years and working with almost all the so-called 03 tiers(DB, M-Tier, and Client). Recently, he has started working with DevOps technologies such as Azure administration, Kubernetes, Terraform automation, and Bash scripting as well.

Related Article - PowerShell Object