# How to continue the script without waiting for its result

**URL:** <https://forums.powershell.org/t/how-to-continue-the-script-without-waiting-for-its-result/15484>\
**Category:** PowerShell Help\
**Created:** [January 16, 2021, 1:42am UTC](https://forums.powershell.org/t/how-to-continue-the-script-without-waiting-for-its-result/15484 "2021-01-16T01:42:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mrdon](https://avatars.discourse-cdn.com/v4/letter/m/4491bb/32.png) [@mrdon](https://forums.powershell.org/u/mrdon)\
**Post date:** [January 16, 2021, 1:42am UTC](https://forums.powershell.org/t/how-to-continue-the-script-without-waiting-for-its-result/15484/1 "2021-01-16T01:42:37Z")

</div>

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
```

---

<div class="post-metadata">

**Author:** ![rob-simmers](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/rob-simmers/32/1010_2.png) [@rob-simmers](https://forums.powershell.org/u/rob-simmers)\
**Post date:** [January 16, 2021, 11:19am UTC](https://forums.powershell.org/t/how-to-continue-the-script-without-waiting-for-its-result/15484/2 "2021-01-16T11:19:35Z")

</div>

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](https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.management/start-process?view=powershell-7.1) and -Wait.

> **[Calling VBScript from Powershell](https://community.spiceworks.com/topic/2239752-calling-vbscript-from-powershell)**
>
> Function Office\_Uninst {
>     Write-Host ''
>     $Office = Get-Package -ProviderName Programs -Name "Microsoft Office\*" -AllVersions
>     $Office\_Prod = $Office.Name
>     $Argument...

---

<div class="post-metadata">

**Author:** ![kardock](https://avatars.discourse-cdn.com/v4/letter/k/779978/32.png) [@kardock](https://forums.powershell.org/u/kardock)\
**Post date:** [January 18, 2021, 2:30am UTC](https://forums.powershell.org/t/how-to-continue-the-script-without-waiting-for-its-result/15484/3 "2021-01-18T02:30:20Z")

</div>

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

new-job

get-job

wait-job

…

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:27pm UTC](https://forums.powershell.org/t/how-to-continue-the-script-without-waiting-for-its-result/15484/4 "2024-05-16T20:27:59Z")

</div>


