The ActiveSessions[0] might have been closed by the loop after.
This caused an error while trying to use Import-PSSession on an already closed and disposed session.
To fix this, just check for active sessions after closing the already open connections
The
ActiveSessions[0]
might have been closed by the loop after. This caused an error while trying to useImport-PSSession
on an already closed and disposed session.To fix this, just check for active sessions after closing the already open connections