Skip to content

How-to

Task-oriented recipes. Each page solves one concrete problem and assumes the basics from Tutorials .

How To Write A Cmdlet
Parameters and their attributes, the three phases, output, errors, streams, ShouldProcess, cancellation.
How To Return Objects
Copied, proxy and psobject classes, enums, arrays, hashtables, and when to pick which.
How To Write A Provider
The Provider trait mapped onto NavigationCmdletProvider, with the in-memory filesystem as the worked example.
How To Add Completers, Transforms And Dynamic Parameters
Tab completion from Rust, arguments changed before the binder coerces them, and parameters that appear depending on what was bound.
How To Call .NET From Rust
Properties, methods, statics, constructors, script blocks, and zero-copy primitive arrays.
How To Use Threads
stream_from_thread, par_map, the pipeline-thread rule, and cancellation.
How To Test A Module
Pester in both hosts through cargo pwrs test, the fake host for Rust unit tests, the in-process engine host.
How To Add Hybrid C#
Hand-written C# cmdlets compiled into the same shell assembly.
How To Publish
cargo pwrs publish, the dry run, and the gallery key.
How To Make A Module Fast
Pipeline input against per-invocation calls, the phase mask, bulk data through a pin, and what each is worth.
How To Use Instruction Sets
AVX2, AVX-512 and the rest on both hosts: run-time dispatch, the import check, and every tier tested on one machine.
How To Pass Native Data Between Cmdlets
One object per stage taken by type, the object’s gate, telling the collector what it holds, and what the rows cost.
How To Ship A Helper Executable
A [[bin]] target built with the library, shipped beside it, and started from a copy staged for the process.
How To Bundle A Module
Another PWRS module built by the same tool, laid inside this one, imported with it, and carried through publish and merge.
How To Raise Engine Events
PsEvents from any thread, during the call and after it, read in script by Wait-Event, Get-Event and Register-EngineEvent -Action.
How To Trace A Module
PWRS_TRACE, the counters on both sides, and how to read a line.
How To Reload A Module
Picking up a rebuild in a live session, why nothing is unloaded, and what that costs.
How To Fix A Failure
What each failure means, keyed by the text you see; the crate and cargo-pwrs move together.