Created
July 2, 2019 15:12
-
-
Save ismits/641abb9af87c2d93c3206c12ae582d77 to your computer and use it in GitHub Desktop.
PowerShell function to wait for an async task to complete and return the result when completed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Get-AsyncResult { | |
[CmdletBinding()] | |
[OutputType('Object')] | |
param ( | |
[Parameter(Mandatory = $true, Position = 1)] | |
[object] $Task | |
) | |
Write-PSFMessage -Level Verbose -Message "Building the Task Waiter and start waiting." -Target $Task | |
$Task.GetAwaiter().GetResult() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment