Disconnect-XenServer
Closes a session with a XenServer host.
Syntax
Disconnect-XenServer [[-Session] <Session>] [<CommonParameters>]
Disconnect-XenServer [[-Ref] <XenRef[Session]>] [<CommonParameters>]
Description
Logs out of a XenServer session and removes it from the set of connections the other cmdlets can use.
Sessions do not last forever, but they do not expire the moment a script ends either, so a long-running script that connects repeatedly should disconnect as well.
Parameters
-Ref
The opaque reference of the session to close.
| Attribute | Value |
|---|---|
| Type | XenRef[Session] |
| Required | False |
| Position | 0 |
| Accepts pipeline input | True (ByPropertyName) |
| Aliases | opaque_ref |
-Session
The session to close, as returned by Get-XenSession or by Connect-XenServer -PassThru.
| Attribute | Value |
|---|---|
| Type | Session |
| Required | False |
| Position | 0 |
| Accepts pipeline input | True (ByValue) |
Inputs
-
Session -
XenRef[Session]
Examples
Example 1: Disconnect every open session
PS> Get-XenSession | Disconnect-XenServer
Closes all the sessions this module holds, which is the usual way to tidy up at the end of a script.
Example 2: Disconnect one server
PS> Get-XenSession -Url https://myserver | Disconnect-XenServer
Leaves any other connections open.
Example 3: Disconnect a session held in a variable
PS> $session = Connect-XenServer -Url https://myserver -Creds (Get-Credential) -PassThru
PS> Disconnect-XenServer -Session $session
The session returned by -PassThru can be closed directly.
Related links
-
Using the XenServer PowerShell module