Search code examples
powershellpowershell-remoting

Hold PSSession in a global context


I want to create a few PSSessions and hold them in the background. So later I can connect to a maschine through these PSSessions.

This should work between different PowerShell instances.

My very naive approach didn't work.

set-variable -name Sessions -value $sessions -scope global 

Solution

  • It is not possible to retrieve sessions running in a separate PS instance(that is a process with different PID to the calling process).