Get-XenSession

Last published : Nov 12, 2026
Gets the sessions this module has open.

Syntax

Get-XenSession [-Ref <XenRef[Session]>] [<CommonParameters>]
Get-XenSession -Url <string> [<CommonParameters>]
Get-XenSession -Server <string> [-Port <int>] [<CommonParameters>]
Get-XenSession -UserName <string> [<CommonParameters>]

Description

Returns the XenServer sessions currently open, optionally narrowed to one server or user.
This reports what this PowerShell session holds; it does not ask a server which sessions exist on it.

Parameters

-Port

The port the server was connected on. Defaults to 443.
Attribute Value
Type int
Required False
Position Named
Accepts pipeline input False

-Ref

The opaque reference of the session to return.
Attribute Value
Type XenRef[Session]
Required False
Position Named
Accepts pipeline input True (ByPropertyName)
Aliases opaque_ref

-Server

Returns the sessions open with the server at this address.
Attribute Value
Type string
Required True
Position Named
Accepts pipeline input False
Aliases svr

-Url

Returns the sessions open with the server at this URL.
Attribute Value
Type string
Required True
Position Named
Accepts pipeline input False

-UserName

Returns the sessions opened by this user.
Attribute Value
Type string
Required True
Position Named
Accepts pipeline input False

Inputs

  • XenRef[Session]

Outputs

  • Session[]

Examples

Example 1: List every open session

PS> Get-XenSession
Shows what this PowerShell session is connected to.

Example 2: Find the session for one server

PS> Get-XenSession -Url https://myserver
Useful when several servers are connected at once and a cmdlet needs to be told which to act on.

Example 3: Target a cmdlet at one connection

PS> $session = Get-XenSession -Url https://myserver
PS> Get-XenVM -SessionOpaqueRef $session.opaque_ref
Every cmdlet takes -SessionOpaqueRef, which overrides the default session for that one call.