MonadicSoftware.PowerShellAsync 2.0.0

Prefix Reserved
dotnet add package MonadicSoftware.PowerShellAsync --version 2.0.0
                    
NuGet\Install-Package MonadicSoftware.PowerShellAsync -Version 2.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="MonadicSoftware.PowerShellAsync" Version="2.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MonadicSoftware.PowerShellAsync" Version="2.0.0" />
                    
Directory.Packages.props
<PackageReference Include="MonadicSoftware.PowerShellAsync" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add MonadicSoftware.PowerShellAsync --version 2.0.0
                    
#r "nuget: MonadicSoftware.PowerShellAsync, 2.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package MonadicSoftware.PowerShellAsync@2.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=MonadicSoftware.PowerShellAsync&version=2.0.0
                    
Install as a Cake Addin
#tool nuget:?package=MonadicSoftware.PowerShellAsync&version=2.0.0
                    
Install as a Cake Tool

.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

Luiz (luiz.monad@gmail.com)

License

MIT

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.0.0 164 1/10/2025

# Changelog  ## 2.0.0 (2025-01-10)   ### ⚠ BREAKING CHANGES  * publish nuget package * implemented cancellation * implemented ThreadAffinitiveSynchronizationContext based on PSKubeCtl * upgrade project to dotnet8  ### Features  * implemented cancellation ([f47fc06](https://github.com/Luiz-Monad/PowerShellAsync/commit/f47fc0613a3cb9cc7f742eb9a31e1ff522a6f278)) * implemented ThreadAffinitiveSynchronizationContext based on PSKubeCtl ([13ac7ac](https://github.com/Luiz-Monad/PowerShellAsync/commit/13ac7acbc71cc6813f5156f4d4e0ebea0affd08a))   ### Bug Fixes  * cancellation ([9efdcf8](https://github.com/Luiz-Monad/PowerShellAsync/commit/9efdcf8c41686266d05bded6065543a7b02f3799)) * CI fix ([7f0b9c5](https://github.com/Luiz-Monad/PowerShellAsync/commit/7f0b9c5c3d14ed4827e77c842588c3f29b65df28)) * deadlock on ThreadAffinitiveSynchronizationContext ([e5c6977](https://github.com/Luiz-Monad/PowerShellAsync/commit/e5c697796ab6ae83bce331587dcf8d48f28bb75b)) * disposed on cancellation ([b663f4b](https://github.com/Luiz-Monad/PowerShellAsync/commit/b663f4b2d375187ada97d8aba166cd2afa678e1c)) * github CI workflow ([f74eb36](https://github.com/Luiz-Monad/PowerShellAsync/commit/f74eb368c30d4b7c9bf0fc74b708bc9d29999fc3)) * nuget package validation ([2adaba0](https://github.com/Luiz-Monad/PowerShellAsync/commit/2adaba0e47d57e62a7da5c3b8204ba4fd6379409)) * tests ([5559632](https://github.com/Luiz-Monad/PowerShellAsync/commit/5559632c3609d9c07276dbab01f77e0cb3a5132b)) * tests ([3fe130f](https://github.com/Luiz-Monad/PowerShellAsync/commit/3fe130fb218ebad5c5d22e2c1938e569856afc59)) * tests - reproduce deadlock ([a3cc39e](https://github.com/Luiz-Monad/PowerShellAsync/commit/a3cc39e55c5a9cbc0bb665569567ee7209a65628)) * workflow release-please ([438d244](https://github.com/Luiz-Monad/PowerShellAsync/commit/438d244acba6d2b105aa35dc6508f7183e587ac8))   ### Miscellaneous Chores  * publish nuget package ([e3bdab3](https://github.com/Luiz-Monad/PowerShellAsync/commit/e3bdab30bcafd29d3f845b7fbc35c07ba7a6b413)) * release 2.0.0 ([b7eb962](https://github.com/Luiz-Monad/PowerShellAsync/commit/b7eb962edf207e000f6a03320ccd4b5d43a181e3)) * upgrade project to dotnet8 ([2fd31f4](https://github.com/Luiz-Monad/PowerShellAsync/commit/2fd31f4d868ae5726bada6fdf3a5f638e3400851))  ## [0.0.0] legacy (2022-08-13)   ### Features  * 1.1.0.1     * Fixed CI workflow * 1.1.0.0     * .NET Core 3.1 Support     * Removed dependency on Jetbrains.Annoations * 1.0.1.0     * Bug fixes * 1.0.0.0     * Initial Release