PSWasm is a proof-of-concept WebAssembly runtime that runs browser-safe PowerShell-compatible scripts in static web pages. It does not require a build-time PowerShell-to-C# conversion step.
Try the hosted browser sample or edit the examples in CodePen.
To use PSWasm in your own page, add the hosted loader to a page served over HTTP:
<script type="pwsh">
$Name = 'PSWasm'
Write-Output "Hello $Name"
</script>
<script type="module" src="https://ayanmullick.github.io/PSWasm/app.js"></script>PowerShell can also live in a same-origin .ps1 file. The web flavor includes DOM interaction and browser HTTP commands:
<script type="pwsh" src="./sample.ps1"></script>
<script type="module" src="https://ayanmullick.github.io/PSWasm/web/app.js"></script>Inline and external scripts run in document order and share a runtime session. Browser fetch rules, including CORS, apply. For scripts that update the DOM directly, data-pswasm-output="none" hides the generated success-output box while preserving errors. See Browser Usage.
Prerequisites: Git, the .NET 10 SDK selected by global.json, the wasm-tools workload, and the dotnet-serve tool for the local server. PowerShell 7 is required for the repository's .ps1 tooling. See setup and validation details.
Clone the repository, then publish and serve the browser sample:
git clone https://github.com/Ayanmullick/PSWasm.git
cd PSWasm
dotnet publish ./samples/BrowserHost/PSWasm.BrowserHost.csproj -c Release -r browser-wasm `
-o ./.WorkDir/build/publish/BrowserHost /p:UseAppHost=false
dotnet serve --directory ./.WorkDir/build/publish/BrowserHost/wwwroot --port 5010 --address 127.0.0.1Open http://127.0.0.1:5010/. Publishing restores dependencies and builds the sample; add --no-restore only when matching restore assets already exist. Stop the server with Ctrl+C. Generated build output stays under .WorkDir/build/.
To build only the runtime, without publishing the browser sample:
dotnet build ./src/PowerShell.Wasm/PowerShell.Wasm.csproj -c ReleaseUse the hosted loader above, or publish files to serve with your app:
pwsh -NoProfile -File ./tools/Publish-BrowserFlavors.ps1 -Flavor webCopy app.js, app.d.ts, and _framework/** from .WorkDir/build/publish/BrowserFlavors/web/wwwroot/ together. The public tooling has two entry points:
- Publish-BrowserFlavors.ps1 publishes
core,web,AzAuth, orfullpackages, with optional versioned hosting folders. - Measure-BrowserPayload.ps1 reports raw and compressed payload sizes.
The AzAuth flavor adds user-delegated Entra authentication and authenticated Azure REST calls. See Runtime Flavors and Payload Optimization and Azure Auth Cmdlets.
The runtime includes PowerShell-style variables, arrays, hashtables, objects, operators, functions, control flow, splatting, pipelines, stream output, and a limited set of .NET helpers. Browser commands cover JSON/CSV/HTML conversion, DOM events and storage, HTTP requests, and optional Azure authentication.
Use & to invoke a script block or a registered command/function by name. See call-operator binding and scope for named arguments, switches, and splatting.
PSWasm does not provide the full desktop/server PowerShell host. Providers, native processes, profiles, remoting, jobs, unrestricted filesystem access, module autoloading, and arbitrary .NET reflection are outside its browser-safe scope.
- Runtime Scope and Language Support: numeric types and operators, assignment evaluation, output capture and pipelines, and function binding
- Browser Commands
- DOM Cmdlets and DOM Cmdlet Reference
- Browser Usage
- Azure Auth Cmdlets and Invoke-AzRestMethod
- Build and Validation: prerequisites, maintainer checks, output cleanup, and GitHub Pages deployment
- Browser DOM Smoke: run browser assertions and submit their JSON report
- Architecture and Direction
Runtime verification, browser packaging, and DOM smoke checks are documented separately from the quick start.
PSWasm is available under the MIT License.