PS sessions use Windows remoting to communicate between servers. PS sessions can be used for anything from remote command and script execution to providing a remote shell.
Sessions are created using the New-PSSession
command. In the following example, a session is created on a computer named PSTEST
:
PS> New-PSSession -ComputerName PSTEST Id Name ComputerName State ConfigurationName Availability -- ---- ------------ ----- ----------------- ------------ 1 Session1 PSTEST Opened Microsoft.PowerShell Available
Sessions created using New-PSSession
persist until the PS session is removed (by Remove-PSSession
) or the PowerShell session ends. The following example returns sessions created in the current PowerShell session:
PS> Get-PSSession | Select-Object Id, ComputerName, State Id ComputerName State -- ------------ ----- 1 PSTEST Opened
If the ComputerName
parameter is supplied, Get-PSSession
will show sessions created on that computer. For example...