PowerShell Logo Small

Get-CimAssociatedInstance



This is the built-in help made by Microsoft for the command 'Get-CimAssociatedInstance', 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.

SYNOPSIS

Retrieves the CIM instances that are connected to a specific CIM instance by an association.

SYNTAX


Get-CimAssociatedInstance [-InputObject] <CimInstance> [[-Association] <String>] [-ComputerName <String[]>] [-KeyOnly] [-Namespace <String>] [-OperationTimeoutSec <UInt32>]
[-ResourceUri <Uri>] [-ResultClassName <String>] [<CommonParameters>]
Get-CimAssociatedInstance [-InputObject] <CimInstance> [[-Association] <String>] [-KeyOnly] [-Namespace <String>] [-OperationTimeoutSec <UInt32>] [-ResourceUri <Uri>]
[-ResultClassName <String>] -CimSession <CimSession[]> [<CommonParameters>]



Search powershellhelp.space

DESCRIPTION


The Get-CimAssociatedInstance cmdlet retrieves the CIM instances connected to a specific CIM instance, called the source instance, by an association.


In an association, each CIM instance has a named role and the same CIM instance can participate in an association in different roles.


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.











<

RELATED LINKS

Get-CimClass
Get-CimInstance

REMARKS

<

Examples


Example 1: Get all the associated instances of a specific instance

PS C:\>$disk = Get-CimInstance -ClassName Win32_LogicalDisk -KeyOnly


PS C:\>Get-CimAssociatedInstance -InputObject $disk[1]



This set of commands retrieves the instances of the class named Win32_LogicalDisk and stores the information in a variable named $disk using the Get-CimInstance cmdlet. The
first logical disk instance in the variable is then used as the input object for the Get-CimAssociatedInstance cmdlet to get all the associated CIM instances of the
specified CIM instance.






Example 2: Get all the associated instances of a specific type

PS C:\>$disk = Get-CimInstance -ClassName Win32_LogicalDisk -KeyOnly


PS C:\>Get-CimAssociatedInstance -InputObject $disk[1] -ResultClass Win32_DiskPartition



This set of commands retrieves all of the instances of the class named Win32_LogicalDisk and stores them in a variable named $disk. The first logical disk instance in the
variable is then used as the input object for the Get-CimAssociatedInstance cmdlet to get all the associated instances that are associated through the specified association
class Win32_DiskPartition.






Example 3: Get all the associated instances through qualifier of a specific class

PS C:\>$s = Get-CimInstance -Query "Select * from Win32_Service where name like ꞌWinmgmtꞌ"



PS C:\>Get-CimClass -ClassName *Service* -Qualifier "Association"



PS C:\>$c.CimClasName
Win32_LoadOrderGroupServiceDependencies


Win32_DependentService


Win32_SystemServices


Win32_LoadOrderGroupServiceMembers


Win32_ServiceSpecificationService


PS C:\>Get-CimAssociatedInstance -InputObject $s -Association Win32_DependentService



This set of commands retrieves the services that depend on Windows Management Instrumentation (WMI) service and stores them in a variable named $s. The association class
name for the Win32_DependentService is retrieved using the Get-CimClass cmdlet by specifying Association as the qualifier and is then passed with $s to the
Get-CimAssociatedInstance cmdlet to get all the associated instances of the retrieved association class.