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 <noreply@anthropic.com>
This commit is contained in:
2026-05-24 00:53:19 +02:00
parent de6858e3df
commit 6b76115b6a
2 changed files with 12 additions and 0 deletions
+6
View File
@@ -165,6 +165,12 @@ Set-StrictMode -Version Latest
$ErrorActionPreference = 'Stop' $ErrorActionPreference = 'Stop'
$ProgressPreference = 'SilentlyContinue' # suppress Write-Progress (IWR, etc.) $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 { function Test-TcpPort {
param([string]$ComputerName, [int]$Port, [int]$TimeoutMs = 3000) param([string]$ComputerName, [int]$Port, [int]$TimeoutMs = 3000)
try { try {
+6
View File
@@ -165,6 +165,12 @@ Set-StrictMode -Version Latest
$ErrorActionPreference = 'Stop' $ErrorActionPreference = 'Stop'
$ProgressPreference = 'SilentlyContinue' # suppress Write-Progress (IWR, etc.) $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 { function Test-TcpPort {
param([string]$ComputerName, [int]$Port, [int]$TimeoutMs = 3000) param([string]$ComputerName, [int]$Port, [int]$TimeoutMs = 3000)
try { try {