How to continue the script without waiting for its result when running some file in PSsession. The script below executes. Vbs file. However, it needs to wait for its result before moving to the next.
Try { $MySession2 = New-PSSession -ComputerName $Server -ErrorAction Stop; Write-Host "Done" -ForegroundColor Green } Catch { Write-Host "Failed" -ForegroundColor Red; Write-Host "`n"; Continue } Finally { $Error.Clear() } $MyCommands = { Write-Host "Running InstallUpdatesh.vbs : " -NoNewline cd "C:\Patches" cmd.exe /c "InstallUpdatesh.vbs" | Out-Null Write-Host "Done" } Invoke-Command -Session $MySession2 -ScriptBlock $MyCommands