This is the built-in help made by Microsoft for the command 'Get-CimInstance', in PowerShell version 5 - as retrieved from
Windows version 'Microsoft Windows Server 2012 R2 Standard' PowerShell help files on 2016-06-23.
For PowerShell version 3 and up, where you have Update-Help, this command was run just before creating the web pages from the help files.
Gets the CIM instances of a class from a CIM server.
Get-CimInstance [-ClassName] <String> [-ComputerName <String[]>] [-Filter <String>] [-KeyOnly] [-Namespace <String>] [-OperationTimeoutSec <UInt32>] [-Property <String[]>]
[-QueryDialect <String>] [-Shallow] [<CommonParameters>]
Get-CimInstance [-Filter <String>] [-KeyOnly] [-Namespace <String>] [-OperationTimeoutSec <UInt32>] [-Property <String[]>] [-Shallow] -CimSession <CimSession[]> -ResourceUri
<Uri> [<CommonParameters>]
Get-CimInstance [-InputObject] <CimInstance> [-OperationTimeoutSec <UInt32>] [-ResourceUri <Uri>] -CimSession <CimSession[]> [<CommonParameters>]
Get-CimInstance [-Namespace <String>] [-OperationTimeoutSec <UInt32>] [-QueryDialect <String>] [-ResourceUri <Uri>] [-Shallow] -CimSession <CimSession[]> -Query <String>
[<CommonParameters>]
Get-CimInstance [-ClassName] <String> [-Filter <String>] [-KeyOnly] [-Namespace <String>] [-OperationTimeoutSec <UInt32>] [-Property <String[]>] [-QueryDialect <String>]
[-Shallow] -CimSession <CimSession[]> [<CommonParameters>]
Get-CimInstance [-ComputerName <String[]>] [-Filter <String>] [-KeyOnly] [-Namespace <String>] [-OperationTimeoutSec <UInt32>] [-Property <String[]>] [-Shallow] -ResourceUri
<Uri> [<CommonParameters>]
Get-CimInstance [-ComputerName <String[]>] [-Namespace <String>] [-OperationTimeoutSec <UInt32>] [-QueryDialect <String>] [-ResourceUri <Uri>] [-Shallow] -Query <String>
[<CommonParameters>]
Get-CimInstance [-InputObject] <CimInstance> [-ComputerName <String[]>] [-OperationTimeoutSec <UInt32>] [-ResourceUri <Uri>] [<CommonParameters>]
The Get-CimInstance cmdlet gets the CIM instances of a class from a CIM server. You can specify either the class name or a query for this cmdlet.
This cmdlet returns one or more CIM instance objects representing a snapshot of the CIM instances present on the CIM server.
If the InputObject parameter is not specified, the cmdlet works in one of the following ways:
--If neither the ComputerName parameter nor the CimSession parameter is specified, then this cmdlet works on local Windows Management Instrumentation (WMI) using a Component
Object Model (COM) session.
--If either the ComputerName parameter or the CimSession parameter is specified, then this cmdlet works against the CIM server specified by either the ComputerName parameter
or the CimSession parameter.
If the InputObject parameter is specified, the cmdlet works in one of the following ways:
--If neither the ComputerName parameter nor the CimSession parameter is specified, then this cmdlet uses the CIM session or computer name from the input object.
--If the either the ComputerName parameter or the CimSession parameter is specified, then this cmdlet uses the either the CimSession parameter value or ComputerName
parameter value. Note: This is not very common.
<
Format-Table
Get-CimAssociatedInstance"
Get-CimAssociatedInstance
Get-CimClass"
Get-CimClass
Invoke-CimMethod
New-CimInstance
Register-CimIndicationEvent"
Register-CimIndicationEvent
Remove-CimInstance
Set-CimInstance
<
Example 1: Get the CIM instances of a specified class
PS C:\> Get-CimInstance -ClassName Win32_Process
This command retrieves the CIM instances of a class named Win32_Process.
Example 2: Get a list of namespaces from a WMI server
PS C:\>Get-CimInstance –Namespace root –ClassName __Namespace
This command retrieves a list of namespaces under the Root namespace on a WMI server.
Example 3: Get instances of a class filtered by using a query
PS C:\>Get-CimInstance -Query "SELECT * from Win32_Process WHERE name LIKE 'p%'"
This command retrieves all the CIM instances that start with the letter p of a class named Win32_Process using the query specified by a Query parameter.
Example 4: Get instances of a class filtered by using a class name and a filter expression
PS C:\>Get-CimInstance -ClassName Win32_Process -Filter "Name like 'p%'"
This command retrieves all the CIM instances that start with the letter p of a class named Win32_Process using the Filter parameter.
Example 5: Get the CIM instances with only key properties filled in
PS C:\>$x = New-CimInstance -ClassName Win32_Process -Namespace root\cimv2 -Property @{ "Handle"=0 } -Key Handle -ClientOnly
The variable is passed as a CIM instance to the Get-CimInstance cmdlet to get a particular instance.
PS C:\>Get-CimInstance -CimInstance $x
This set of commands creates a new CIM instance in memory for a class named Win32_Process with the key property @{ "Handle"=0 } and stores it in a variable named $x.
Example 6: Retrieve CIM instances and reuse them
PS C:\>$x,$y = Get-CimInstance -ClassName Win32_Process
PS C:\>$x| Format-Table -Property Name,KernelModeTime -AutoSize
PS C:\>$x| Get-CimInstance |Format-Table -Property Name,KernelModeTime -AutoSize
This set of commands gets the CIM instances of a class named Win32_Process and stores them in the variables $x and $y. The variable $x is then formatted in a table
containing only the Name and the KernelModeTime attributes, the table set to AutoSize.
Example 7: Get CIM instances from remote computer
PS C:\>Get-CimInstance -ClassName Win32_ComputerSystem -ComputerName Server01,Server02
This command retrieves the CIM instances of a class named Win32_ComputerSystem from the remote computers named Server01 and Server02.
Example 8: Getting only the key properties, instead of all properties
PS C:\>Get-CimInstance -Class Win32_Process -KeyOnly
PS C:\>$x = Get-CimInstance -Class Win32_Process -KeyOnlyPS C:\>$x | Invoke-CimMethod -MethodName GetOwner
This command retrieves only the key properties, which reduces the size of the object and network traffic.
Example 9: Getting only a subset of properties, instead of all properties
PS C:\>Get-CimInstance -Class Win32_Process -Property Name,KernelModeTime
PS C:\>$x = Get-CimInstance -Class Win32_Process -Property Name, KernelModeTimePS C:\>$x | Invoke-CimMethod -MethodName GetOwner
The instance retrieved with the Property parameter can be used to perform other CIM operations, for example Set-CimInstance or Invoke-CimMethod.
PS C:\>$x = Get-CimInstance -Class Win32_Process -Property Name,KernelModeTime
PS C:\>Invoke-CimMethod –InputObject $x -MethodName GetOwner
This command retrieves only a subset of properties, which reduces the size of the object and network traffic.
Example 10: Get the CIM instance using CIM session
PS C:\>$s = New-CimSession –ComputerName Server01,Server02
PS C:\>Get-CimInstance -ClassName Win32_ComputerSystem -CimSession $s
This set of commands creates a CIM session on the computers named Server01 and Server02 using the New-CimSession cmdlet and stores the session information in a variable
named $s. The contents of the variable are then passed to Get-CimInstance by using the CimSession parameter, to get the CIM instances of the class named Win32_ComputerSystem.