February 2019
Intermediate to advanced
626 pages
15h 51m
English
The InDisconnectedSession of Invoke-Command starts the requested script and immediately disconnects the session. This allows a script to be started and collected from a different console session or a different computer.
The session parameter cannot be used with InDisconnectedSession; Invoke-Command creates a new session for a specified computer name. The session is returned by the following command:
Invoke-Command { Start-Sleep -Seconds 120; 'Done' } -ComputerName PSTest -InDisconnectedSession
A second PowerShell session or computer is able to connect to the disconnected session to retrieve the results. The following command assumes that only one session exists with the PSTest computer:
Get-PSSession -ComputerName PSTest ...
Read now
Unlock full access