NAME
Get-CimSession
SYNOPSIS
Gets the CIM session objects from the current session.SYNTAX
Get-CimSession [[-ComputerName]
] [ ] Get-CimSession [-Id]
[ ] Get-CimSession -InstanceId
[ ] Get-CimSession -Name
[ ] DESCRIPTION
The Get-CimSession cmdlet gets the Common Information Model (CIM) session objects created in the current Windows
PowerShellr session. If used without any parameters, the cmdlet gets all of the CIM sessions created in the current Windows PowerShellsession. 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, IDs, or instance IDs. For more information about Windows PowerShell sessions, see about_CimSessions.PARAMETERS
-ComputerName [
Specifies the name of the computer from which to get CIM sessions. Wildcard characters are permitted. Required? false Position? 1 Default value none] Accept pipeline input? true (ByPropertyName)
Accept wildcard characters? false-Id
Specifies the identifier (ID) 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 in the current Windows PowerShell session. It is easier to remember and type than InstanceId, but it is unique only within the current Windows PowerShell session. For more information about the range operator, see about_Operators. Required? true Position? 1 Default value noneAccept pipeline input? true (ByPropertyName)
Accept wildcard characters? false-InstanceId
Specifies the instance IDs of the CIM session to get. InstanceID is a GUID that uniquely identifies a CIM session. The InstanceID is unique, even when you have multiple sessions running in Windows PowerShell. The InstanceID is stored in the InstanceID property of the object that represents a CIM session. Required? true Position? named Default value noneAccept pipeline input? true (ByPropertyName)
Accept wildcard characters? false-Name
Gets one or more CIM sessions which contain the specified friendly names. Wildcard characters are permitted. Required? true Position? named Default value noneAccept pipeline input? true (ByPropertyName)
Accept wildcard characters? falseThis cmdlet supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, WarningVariable, OutBuffer, PipelineVariable, and OutVariable. For more information, see about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216). INPUTS
NoneOUTPUTS
Microsoft.Management.Infrastructure.CimSessionExample 1: Get CIM sessions from the current wps_2 session
PS C:\> New-CimSession -ComputerName "Server01,Server02"
PS C:\> Get-CimSession
Id : 1Name : CimSession1
InstanceId : d1413bc3-162a-4cb8-9aec-4d2c61253d59
ComputerName : Server01
Protocol : WSMAN Id : 2Name : CimSession2
InstanceId : c0095981-52c5-4e7f-a5bb-c4c680541710
ComputerName : Server02
Protocol : WSMANThis command first creates CIM sessions by using New-CimSession, and then gets the CIM sessions by using
Get-CimSession.
By default, Get-CimSession only gets information about the CIM sessions that exist in the current Windows
PowerShell session. Get-CimSession does not get CIM sessions that were created in other Windows PowerShell
sessions or that were created on other computers.Example 2: Get the CIM sessions from a specific computer
PS C:\>Get-CimSession -ComputerName "Server02"
Id : 2Name : CimSession2
InstanceId : c0095981-52c5-4e7f-a5bb-c4c680541710
ComputerName : Server02
Protocol : WSMAN This command gets the CIM sessions that are connected to the computer named Server02.Example 3: Get a list of CIM sessions and then format the list
PS C:\>Get-CimSession | Format-Table -Property ComputerName,InstanceID
This command gets all of the CIM sessions in the current Windows PowerShell session, and then formats the list ina table containing only the ComputerName and InstanceID parameters.
Example 4: Get all CIM sessions that have specific names
PS C:\>Get-CimSession -ComputerName "Serv*"
Id : 1Name : CimSession1
InstanceId : d1413bc-162a-4cb8-9aec-4d2c61253d59
ComputerName : Server01
Protocol : WSMAN Id : 2Name : CimSession2
InstanceId : c0095981-52c5-4e7f-a5bb-c4c680541710
ComputerName : Server02
Protocol : WSMAN This command gets all of the CIM sessions that have names that begin with the characters serv.Example 5: Get a specific CIM session
PS C:\>Get-CimSession -ID 2
This command gets the CIM session that has an ID of 2.RELATED LINKS
Online Version:New-CimSession
Remove-CimSession