다음을 통해 공유


Get-CimSession

Gets the CIM session objects from the current session.

구문

ComputerNameSet (기본값)

Get-CimSession
    [[-ComputerName] <String[]>]
    [<CommonParameters>]

SessionIdSet

Get-CimSession
    [-Id] <UInt32[]>
    [<CommonParameters>]

InstanceIdSet

Get-CimSession
    -InstanceId <Guid[]>
    [<CommonParameters>]

NameSet

Get-CimSession
    -Name <String[]>
    [<CommonParameters>]

Description

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.

예제

Example 1: Get CIM sessions from the current PowerShell session

This example creates CIM sessions using New-CimSession, and then gets the CIM sessions using Get-CimSession.

New-CimSession -ComputerName Server01, Server02
Get-CimSession
Id           : 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

Example 2: Get the CIM sessions to a specific computer

This example gets the CIM sessions that are connected to the computer named Server02.

Get-CimSession -ComputerName Server02
Id           : 2
Name         : CimSession2
InstanceId   : c0095981-52c5-4e7f-a5bb-c4c680541710
ComputerName : Server02
Protocol     : WSMAN

Example 3: Get a list of CIM sessions and then format the list

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, InstanceId
ComputerName InstanceId
------------ ----------
Server01     d1413bc3-162a-4cb8-9aec-4d2c61253d59
Server02     c0095981-52c5-4e7f-a5bb-c4c680541710

Example 4: Get all the CIM sessions that have specific names

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

Example 5: Get a specific CIM session

This example gets the CIM session that has an Id of 2.

Get-CimSession -Id 2
Id           : 2
Name         : CimSession2
InstanceId   : c0095981-52c5-4e7f-a5bb-c4c680541710
ComputerName : Server02
Protocol     : WSMAN

매개 변수

-ComputerName

Specifies the name of the computer to get CIM sessions connected to. Wildcard characters are permitted.

매개 변수 속성

형식:

String[]

Default value:None
와일드카드 지원:True
DontShow:False
별칭:CN, ServerName

매개 변수 집합

ComputerNameSet
Position:0
필수:False
파이프라인의 값:False
속성 이름별 파이프라인의 값:True
나머지 인수의 값:False

-Id

Specifies 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.

매개 변수 속성

형식:

UInt32[]

Default value:None
와일드카드 지원:False
DontShow:False

매개 변수 집합

SessionIdSet
Position:0
필수:True
파이프라인의 값:False
속성 이름별 파이프라인의 값:True
나머지 인수의 값:False

-InstanceId

Specifies 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.

매개 변수 속성

형식:

Guid[]

Default value:None
와일드카드 지원:False
DontShow:False

매개 변수 집합

InstanceIdSet
Position:Named
필수:True
파이프라인의 값:False
속성 이름별 파이프라인의 값:True
나머지 인수의 값:False

-Name

Gets one or more CIM sessions which contain the specified friendly names. Wildcard characters are permitted.

매개 변수 속성

형식:

String[]

Default value:None
와일드카드 지원:True
DontShow:False

매개 변수 집합

NameSet
Position:Named
필수:True
파이프라인의 값:False
속성 이름별 파이프라인의 값:True
나머지 인수의 값:False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

입력

None

You can't pipe objects to this cmdlet.

출력

CimSession

This cmdlet returns a CIM session object.