February 2019
Intermediate to advanced
626 pages
15h 51m
English
EndInvoke is one of two possible ways to get output from a PowerShell instance. The EndInvoke method may be called as follows:
$psInstance = [PowerShell]::Create()$asyncResult = $psInstance.AddScript('1..10').BeginInvoke()$psInstance.EndInvoke($asyncResult)
If the invocation has not finished, EndInvoke will block execution until it has completed.
The second possible method involves passing a PSDataCollection object to the BeginInvoke method:
$instanceInput = [System.Management.Automation.PSDataCollection[PSObject]]::new()$instanceOutput = [System.Management.Automation.PSDataCollection[PSObject]]::new()$psInstance = [PowerShell]::Create()$asyncResult = $psInstance.AddScript(' 1..10 | ForEach-Object ...Read now
Unlock full access