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:
@@ -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 {
|
||||||
|
|||||||
@@ -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 {
|
||||||
|
|||||||
Reference in New Issue
Block a user