Skip to content

Latest commit

 

History

History
54 lines (29 loc) · 1.56 KB

readme.md

File metadata and controls

54 lines (29 loc) · 1.56 KB

.NET Core

PowerShellAsync

base class for async-enabled PowerShell Cmdlets.

When you build PowerShell Cmdlets, it is required that calls to WriteObject, WriteVerbose, WriteWarning, etc be originated from BeginProcessing/ProcessRecord/EndProcessing method on the main thread!.

With a general move towards async code, it's become hard to use newer libraries inside the traditional PowerShell Cmdlets. Up until now :)

With 3 easy steps you can take advantage of the async programming:

  1. Install PowerShellAsync from nuget.org
  • PM> Install-Package PowerShellAsync
  1. Replace base class of your Cmdlet from PSCmdlet to AsyncCmdlet
  • [Cmdlet("Test", "SomethingCool")] public class TestSomethingCool : AsyncCmdlet
  1. Replace BeginProcessing/ProcessRecord/EndProcessing methods with their xxxAsync counterparts
  • protected override async Task ProcessRecordAsync()
  1. Enjoy!!!

Contributors

Installation

To install PowerShellAsync, run the following command in the Package Manager Console

PM> Install-Package PowerShellAsync

Examples

please take a look at PowerShellAsyncExamples project, it contains an demo Cmdlet that can execute SQL statement on multiple servers takeing advantage of async API.

Contact

Vladimir ([email protected])

License

MIT