From 6b76115b6a0d234e851440cef426fac8cbc6c3f0 Mon Sep 17 00:00:00 2001 From: Simone Date: Sun, 24 May 2026 00:53:19 +0200 Subject: [PATCH] fix(templates): import PSWSMan module on Linux before New-PSSession Without Import-Module PSWSMan the native WSMan library isn't registered and New-PSSession hangs/fails silently. Import guarded by $IsWindows so Windows PS 5.1 is unaffected. Co-Authored-By: Claude Sonnet 4.6 --- template/Prepare-WinBuild2022.ps1 | 6 ++++++ template/Prepare-WinBuild2025.ps1 | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/template/Prepare-WinBuild2022.ps1 b/template/Prepare-WinBuild2022.ps1 index 5105d97..4f4deed 100644 --- a/template/Prepare-WinBuild2022.ps1 +++ b/template/Prepare-WinBuild2022.ps1 @@ -165,6 +165,12 @@ Set-StrictMode -Version Latest $ErrorActionPreference = 'Stop' $ProgressPreference = 'SilentlyContinue' # suppress Write-Progress (IWR, etc.) +# On Linux, PSWSMan must be imported to register the native WSMan client library. +# Install once: sudo pwsh -c "Install-Module PSWSMan -Force; Install-WSMan" +if ($null -ne $IsWindows -and $IsWindows -eq $false) { + Import-Module PSWSMan -ErrorAction Stop +} + function Test-TcpPort { param([string]$ComputerName, [int]$Port, [int]$TimeoutMs = 3000) try { diff --git a/template/Prepare-WinBuild2025.ps1 b/template/Prepare-WinBuild2025.ps1 index 03956d0..3dbb712 100644 --- a/template/Prepare-WinBuild2025.ps1 +++ b/template/Prepare-WinBuild2025.ps1 @@ -165,6 +165,12 @@ Set-StrictMode -Version Latest $ErrorActionPreference = 'Stop' $ProgressPreference = 'SilentlyContinue' # suppress Write-Progress (IWR, etc.) +# On Linux, PSWSMan must be imported to register the native WSMan client library. +# Install once: sudo pwsh -c "Install-Module PSWSMan -Force; Install-WSMan" +if ($null -ne $IsWindows -and $IsWindows -eq $false) { + Import-Module PSWSMan -ErrorAction Stop +} + function Test-TcpPort { param([string]$ComputerName, [int]$Port, [int]$TimeoutMs = 3000) try {