| external help file | Microsoft.Management.Infrastructure.CimCmdlets.dll-Help.xml | |
|---|---|---|
| Locale | en-US | |
| Module Name | CimCmdlets | |
| ms.date | 06/28/2023 | |
| online version | https://learn.microsoft.com/powershell/module/cimcmdlets/get-cimsession?view=powershell-7.4&WT.mc_id=ps-gethelp | |
| schema | 2.0.0 | |
| aliases |
|
|
| title | Get-CimSession |
Gets the CIM session objects from the current session.
Get-CimSession [[-ComputerName] <String[]>] [<CommonParameters>]
Get-CimSession [-Id] <UInt32[]> [<CommonParameters>]
Get-CimSession -InstanceId <Guid[]> [<CommonParameters>]
Get-CimSession -Name <String[]> [<CommonParameters>]
This cmdlet is only available on the Windows platform.
By default, the cmdlet gets all of the CIM sessions created in the current PowerShell session. You
can use the parameters of Get-CimSession to get the sessions that are for particular computers, or
you can identify sessions by their names or other identifiers. Get-CimSession does not get CIM
sessions that were created in other PowerShell sessions or that were created on other computers.
For more information about CIM sessions, see about_CimSession.
This example creates CIM sessions using New-CimSession, and then gets the CIM
sessions using Get-CimSession.
New-CimSession -ComputerName Server01, Server02
Get-CimSessionId : 1
Name : CimSession1
InstanceId : d1413bc3-162a-4cb8-9aec-4d2c61253d59
ComputerName : Server01
Protocol : WSMAN
Id : 2
Name : CimSession2
InstanceId : c0095981-52c5-4e7f-a5bb-c4c680541710
ComputerName : Server02
Protocol : WSMAN
This example gets the CIM sessions that are connected to the computer named Server02.
Get-CimSession -ComputerName Server02Id : 2
Name : CimSession2
InstanceId : c0095981-52c5-4e7f-a5bb-c4c680541710
ComputerName : Server02
Protocol : WSMAN
This example gets all CIM sessions in the current PowerShell session and displays a table containing only the ComputerName and InstanceId properties.
Get-CimSession | Format-Table -Property ComputerName, InstanceIdComputerName InstanceId
------------ ----------
Server01 d1413bc3-162a-4cb8-9aec-4d2c61253d59
Server02 c0095981-52c5-4e7f-a5bb-c4c680541710
This example gets all CIM sessions that have names that begin with Serv.
Get-CimSession -ComputerName Serv*Id : 1
Name : CimSession1
InstanceId : d1413bc-162a-4cb8-9aec-4d2c61253d59
ComputerName : Server01
Protocol : WSMAN
Id : 2
Name : CimSession2
InstanceId : c0095981-52c5-4e7f-a5bb-c4c680541710
ComputerName : Server02
Protocol : WSMAN
This example gets the CIM session that has an Id of 2.
Get-CimSession -Id 2Id : 2
Name : CimSession2
InstanceId : c0095981-52c5-4e7f-a5bb-c4c680541710
ComputerName : Server02
Protocol : WSMAN
Specifies the name of the computer to get CIM sessions connected to. Wildcard characters are permitted.
Type: System.String[]
Parameter Sets: ComputerNameSet
Aliases: CN, ServerName
Required: False
Position: 0
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: TrueSpecifies the identifier of the CIM session to get. For multiple IDs, use commas to separate the IDs
or use the range operator (..) to specify a range of IDs. An Id is an integer that uniquely
identifies the CIM session within the current PowerShell session.
For more information about the range operator, see about_Operators.
Type: System.UInt32[]
Parameter Sets: SessionIdSet
Aliases:
Required: True
Position: 0
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: FalseSpecifies the instance IDs of the CIM session to get.
InstanceId is a globally-unique identifier (GUID) that uniquely identifies a CIM session. The InstanceId is unique, even when you have multiple sessions running in PowerShell.
The InstanceId is stored in the InstanceId property of the object that represents a CIM session.
Type: System.Guid[]
Parameter Sets: InstanceIdSet
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: FalseGets one or more CIM sessions which contain the specified friendly names. Wildcard characters are permitted.
Type: System.String[]
Parameter Sets: NameSet
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: TrueThis cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
You can't pipe objects to this cmdlet.
This cmdlet returns a CIM session object.
PowerShell includes the following aliases for Get-CimSession:
- Windows:
gcms
This cmdlet is only available on Windows platforms.