From 323be48c02acf2dbec17936b2aa5483ba7a8e65e Mon Sep 17 00:00:00 2001 From: Frank Tovar Date: Mon, 2 Feb 2026 17:25:23 +0100 Subject: [PATCH] Handle non-string password vars and pass WinRM auth explicitly --- scripts/deploy-ftp.ps1 | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/scripts/deploy-ftp.ps1 b/scripts/deploy-ftp.ps1 index 21c54e3..d794227 100644 --- a/scripts/deploy-ftp.ps1 +++ b/scripts/deploy-ftp.ps1 @@ -47,8 +47,8 @@ function Assert-Tool { Assert-Tool "dotnet" Assert-Tool $WinScpPath -function Read-PlainOrPrompt([string]$Value, [string]$Prompt, [bool]$Secure = $false) { - if ($Value) { return $Value } +function Read-PlainOrPrompt([object]$Value, [string]$Prompt, [bool]$Secure = $false) { + if ($Value -is [string] -and -not [string]::IsNullOrWhiteSpace($Value)) { return $Value } if ($Secure) { $pwd = Read-Host -Prompt $Prompt -AsSecureString $ptr = [Runtime.InteropServices.Marshal]::SecureStringToBSTR($pwd) @@ -62,6 +62,7 @@ function Read-PlainOrPrompt([string]$Value, [string]$Prompt, [bool]$Secure = $fa $FtpPassword = Read-PlainOrPrompt $FtpPassword "FTP password" $true $WinRmCredentialPass = Read-PlainOrPrompt $WinRmCredentialPass "WinRM password" $true +$WinRmAuth = "Basic" # Basic for local admin over HTTPS; use Default/Kerberos if joined to domain Write-Host "1) Publishing..." -ForegroundColor Cyan if (Test-Path $PublishDir) { Remove-Item $PublishDir -Recurse -Force -ErrorAction SilentlyContinue } @@ -83,6 +84,7 @@ if ($RecycleAppPool) { } } if ($UseWinRmHttps) { $invokeParams["UseSSL"] = $true } + if ($WinRmAuth) { $invokeParams["Authentication"] = $WinRmAuth } try { Invoke-Command @invokeParams } catch { @@ -118,6 +120,7 @@ if ($RecycleAppPool) { } } if ($UseWinRmHttps) { $invokeParams["UseSSL"] = $true } + if ($WinRmAuth) { $invokeParams["Authentication"] = $WinRmAuth } try { Invoke-Command @invokeParams } catch {