Handle non-string password vars and pass WinRM auth explicitly
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user