Perhaps you can help me with the following challenge:
I want to run a PSSession command in a script, but I want the main script to continue ONLY when the PSSession has ended.
Write-Host "Starting remote session..." $PSSession = New-PSSession "$Server" -Authentication Credssp -Credential $Credential Enter-PSSession -Session $PSSession ## SHOW WHEN REMOTE SESSIE HAS ENDED Write-Host "Remote session ended" # Continue script
When I try it like above, the script will continue and leaving the session open in the process. If anyone has an idea how to make the script wait before continuing, please let me know!
Thanks and regards,