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 "dotnet"
|
||||||
Assert-Tool $WinScpPath
|
Assert-Tool $WinScpPath
|
||||||
|
|
||||||
function Read-PlainOrPrompt([string]$Value, [string]$Prompt, [bool]$Secure = $false) {
|
function Read-PlainOrPrompt([object]$Value, [string]$Prompt, [bool]$Secure = $false) {
|
||||||
if ($Value) { return $Value }
|
if ($Value -is [string] -and -not [string]::IsNullOrWhiteSpace($Value)) { return $Value }
|
||||||
if ($Secure) {
|
if ($Secure) {
|
||||||
$pwd = Read-Host -Prompt $Prompt -AsSecureString
|
$pwd = Read-Host -Prompt $Prompt -AsSecureString
|
||||||
$ptr = [Runtime.InteropServices.Marshal]::SecureStringToBSTR($pwd)
|
$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
|
$FtpPassword = Read-PlainOrPrompt $FtpPassword "FTP password" $true
|
||||||
$WinRmCredentialPass = Read-PlainOrPrompt $WinRmCredentialPass "WinRM 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
|
Write-Host "1) Publishing..." -ForegroundColor Cyan
|
||||||
if (Test-Path $PublishDir) { Remove-Item $PublishDir -Recurse -Force -ErrorAction SilentlyContinue }
|
if (Test-Path $PublishDir) { Remove-Item $PublishDir -Recurse -Force -ErrorAction SilentlyContinue }
|
||||||
@@ -83,6 +84,7 @@ if ($RecycleAppPool) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($UseWinRmHttps) { $invokeParams["UseSSL"] = $true }
|
if ($UseWinRmHttps) { $invokeParams["UseSSL"] = $true }
|
||||||
|
if ($WinRmAuth) { $invokeParams["Authentication"] = $WinRmAuth }
|
||||||
try {
|
try {
|
||||||
Invoke-Command @invokeParams
|
Invoke-Command @invokeParams
|
||||||
} catch {
|
} catch {
|
||||||
@@ -118,6 +120,7 @@ if ($RecycleAppPool) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($UseWinRmHttps) { $invokeParams["UseSSL"] = $true }
|
if ($UseWinRmHttps) { $invokeParams["UseSSL"] = $true }
|
||||||
|
if ($WinRmAuth) { $invokeParams["Authentication"] = $WinRmAuth }
|
||||||
try {
|
try {
|
||||||
Invoke-Command @invokeParams
|
Invoke-Command @invokeParams
|
||||||
} catch {
|
} catch {
|
||||||
|
|||||||
Reference in New Issue
Block a user