How to stop an asynchronous PowerShell scriptblock? How to stop an asynchronous PowerShell scriptblock? powershell powershell

How to stop an asynchronous PowerShell scriptblock?


Just like Invoke() has an asynchronous Begin/End pair, so does Stop().

You can wrap them like this to stop invocation:

$ps.EndStop($ps.BeginStop($null,$asyncObject))