How to continue the script without waiting for its result

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

First, I’m not sure what is in the VBS, but VBS is being deprecated and it would be better to build the solution in Powershell that would wait for execution. If you calling an external executable and want to wait, you should look at Start-Process and -Wait.

look at job cmdlets, that will do what you need.

new-job

get-job

wait-job