PowerShell Genie

Get-CimInstance

Use Get-CimInstance to get instances of CIM classes from a CIM server. See CimCmdlets module requirements and examples.

Command 1 min read Windows PowerShell 5.1 and PowerShell 7

Documentation: Microsoft Learn — Get-CimInstance

Syntax

1PS> Get-CimInstance [[-ClassName] <string>] [-ComputerName <String[]>] [-Filter <String>] [-Property <String[]>] [<CommonParameters>]
See the command anatomy

Read the command and its supplied arguments. This example requires real PowerShell or its module; this diagram does not execute it.

Get-CimInstance [[-ClassName] <string>] [-ComputerName <String[]>] [-Filter <String>] [-Property <String[]>] [<CommonParameters>]
  1. Stage 1Get-CimInstance-ClassName -ComputerName -Filter -Property

    Try it

    Windows PowerShell

    PowerShell example · browser support is limited.

    Execution scope: The full example below requires PowerShell outside this browser. You can edit this runner to use the supported practice commands; unsupported syntax returns an explanation.

    Interactive simulation · fictional data

    Examples

    List all with Get-CimInstance

    1PS> Get-CimInstance Win32_OperatingSystem
    Show reference output

    Sample output · fictional data, shaped like the real thing

    SystemDirectory : C:\Windows\system32
    Organization    : Contoso
    BuildNumber     : 26100
    Caption         : Microsoft Windows 11 Pro
    Version         : 10.0.26100
    CSName          : WS01
    LastBootUpTime  : 9/8/2026 6:15:04 AM

    Get-CimInstance -Filter "DriveType=3"

    1PS> Get-CimInstance Win32_LogicalDisk -Filter "DriveType=3"
    Show reference output

    Sample output · fictional data, shaped like the real thing

    DeviceID DriveType ProviderName VolumeName Size         FreeSpace
    -------- --------- ------------ ---------- ------------ ------------
    C:       3                                 255456780288 188888121344
    D:       3                                 999995228160 612345678901

    Show disk sizes in GB

    1PS> Get-CimInstance Win32_LogicalDisk -Filter "DriveType=3" |
    2PS> Select-Object DeviceID, VolumeName,
    3PS> @{N='SizeGB';E={[math]::Round($_.Size/1GB,2)}},
    4PS> @{N='FreeGB';E={[math]::Round($_.FreeSpace/1GB,2)}}
    Show reference output

    Sample output · fictional data, shaped like the real thing

    DeviceID VolumeName SizeGB FreeGB
    -------- ---------- ------ ------
    C:                 237.91 175.92
    D:                 931.32 570.31

    Parameters

    Parameter definitions:

    • -ClassName
    • -ComputerName
    • -Filter
    • -Property

    Get-CimInstance on Microsoft Learn

    Practical use and troubleshooting

    Practical scenario: Use Get-CimInstance when you need to get instances of CIM classes from a CIM server. Start with one identified target and inspect the returned values before extending the operation to a list. Keep the identity in your report so you can trace each result back to the object or path that produced it.

    Common error and fix: Access denied or transport failure requires checking the target, credentials and protocol. Test a local query separately from the remote connection and do not assume ping proves CIM access. In an unattended script, capture this failure with its original error record and record which target failed. An empty result and an unsuccessful query must remain distinguishable in the final report.

    Version note: PowerShell 7 removed the -ComputerName parameter: use New-CimSession to query a remote host instead of copying a Windows PowerShell-only example.

    See also: New-CimSession. Get-CimInstance queries instances; New-CimSession creates a reusable connection description for later CIM calls. A session object is not a hardware inventory result. Read the linked command before substituting it; similar names do not imply identical inputs or output.

    Get-CimInstance reference on Microsoft Learn

    Recap

    Get-CimInstance Use Get-CimInstance to get instances of CIM classes from a CIM server. See CimCmdlets module requirements and examples.

    Next: Get-AzContext
    Genie guideGet-CimInstance

    Use Get-CimInstance to get instances of CIM classes from a CIM server. The console below is pre-loaded — run it, then change a value and run it again.