Remove-CimSession

Removes one or more CIM sessions.

语法

CimSessionSet (默认值)

Remove-CimSession
    [-CimSession] <CimSession[]>
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

ComputerNameSet

Remove-CimSession
    [-ComputerName] <String[]>
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

SessionIdSet

Remove-CimSession
    [-Id] <UInt32[]>
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

InstanceIdSet

Remove-CimSession
    -InstanceId <Guid[]>
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

NameSet

Remove-CimSession
    -Name <String[]>
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

说明

The Remove-CimSession cmdlet removes one or more CIM session objects from the local PowerShell session.

示例

Example 1: Remove all the CIM sessions

Get-CimSession | Remove-CimSession

This command retrieves all the available CIM sessions on the local computer using the Get-CimSession cmdlet, and then removes them using the Remove-CimSession.

Example 2: Remove a specific CIM session

Remove-CimSession -Id 5

This command removes the CIM session that has an ID value of 5.

Example 3: Show the list of CIM sessions to remove by using the WhatIf parameter

Remove-CimSession -Name a* -WhatIf

This command uses the common parameter WhatIf to specify that the removal should not be done, but only output what would happen if it were done.

参数

-CimSession

Specifies the session objects of the CIM sessions to close.

Enter a variable that contains the CIM session, or a command that creates or gets the CIM session, such as the New-CimSession or Get-CimSession cmdlets. For more information, see about_CimSessions.

参数属性

类型:

CimSession[]

默认值:None
支持通配符:False
不显示:False

参数集

CimSessionSet
Position:0
必需:True
来自管道的值:True
来自管道的值(按属性名称):True
来自剩余参数的值:False

-ComputerName

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

参数属性

类型:

String[]

默认值:None
支持通配符:True
不显示:False
别名:CN, ServerName

参数集

ComputerNameSet
Position:0
必需:True
来自管道的值:False
来自管道的值(按属性名称):True
来自剩余参数的值:False

-Confirm

Prompts you for confirmation before running the cmdlet.

参数属性

类型:SwitchParameter
默认值:False
支持通配符:False
不显示:False
别名:cf

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-Id

Specifies the ID of the CIM session to remove. Specify one or more IDs separated by commas, 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 PowerShell session. It is easier to remember and type than InstanceId, but it is unique only within the current PowerShell session.

For more information about the range operator, see about_Operators.

参数属性

类型:

UInt32[]

默认值:None
支持通配符:False
不显示:False

参数集

SessionIdSet
Position:0
必需:True
来自管道的值:False
来自管道的值(按属性名称):True
来自剩余参数的值:False

-InstanceId

Specifies the instance ID of the CIM session to remove.

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[]

默认值:None
支持通配符:False
不显示:False

参数集

InstanceIdSet
Position:Named
必需:True
来自管道的值:False
来自管道的值(按属性名称):True
来自剩余参数的值:False

-Name

Specifies the friendly name of the CIM session to remove. You can use wildcard characters with this parameter.

参数属性

类型:

String[]

默认值:None
支持通配符:True
不显示:False

参数集

NameSet
Position:Named
必需:True
来自管道的值:False
来自管道的值(按属性名称):True
来自剩余参数的值:False

-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

参数属性

类型:SwitchParameter
默认值:False
支持通配符:False
不显示:False
别名:wi

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值: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

This cmdlet accepts no input objects.

输出

Object

This cmdlet returns an object that contains CIM session information.