A simple commandlet that allows usage of async methods
To install AsyncPowerShell, run the following command in the Package Manager Console
PM> Install-Package AsyncPowerShell
Create a new commandlet that inherits from AsyncPowerShell.AsyncPSCmdlet
. Overrides the ProcessRecordAsync
method and implement your commandlet the way you like it!
[Cmdlet(VerbsCommon.Get, "Something")]
public class GetSomethingCommand : AsyncPSCmdlet
{
protected async override Task ProcessRecordAsync()
{
using (var client = new HttpClient())
{
var html = await client.GetStringAsync("https://github.com/fvilers/AsyncPowerShell");
WriteObject(html);
}
}
}
- Version 1.0: AsyncPSCmdlet released
Fabian Vilers
Twitter: @fvilers