Fix password prompt conversion errors
This commit is contained in:
@@ -47,19 +47,21 @@ function Assert-Tool {
|
|||||||
Assert-Tool "dotnet"
|
Assert-Tool "dotnet"
|
||||||
Assert-Tool $WinScpPath
|
Assert-Tool $WinScpPath
|
||||||
|
|
||||||
function Read-PlainOrPrompt([string]$Value, [string]$Prompt, [switch]$Secure) {
|
function Read-PlainOrPrompt([string]$Value, [string]$Prompt, [bool]$Secure = $false) {
|
||||||
if ($Value) { return $Value }
|
if ($Value) { return $Value }
|
||||||
if ($Secure) {
|
if ($Secure) {
|
||||||
$secure = Read-Host -Prompt $Prompt -AsSecureString
|
$secure = Read-Host -Prompt $Prompt -AsSecureString
|
||||||
return [Runtime.InteropServices.Marshal]::PtrToStringUni(
|
$ptr = [Runtime.InteropServices.Marshal]::SecureStringToBSTR($secure)
|
||||||
[Runtime.InteropServices.Marshal]::SecureStringToBSTR($secure)
|
try { return [Runtime.InteropServices.Marshal]::PtrToStringUni($ptr) }
|
||||||
)
|
finally {
|
||||||
|
if ($ptr -ne [IntPtr]::Zero) { [Runtime.InteropServices.Marshal]::ZeroFreeBSTR($ptr) }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return Read-Host -Prompt $Prompt
|
return Read-Host -Prompt $Prompt
|
||||||
}
|
}
|
||||||
|
|
||||||
$FtpPassword = Read-PlainOrPrompt $FtpPassword "FTP password" -Secure
|
$FtpPassword = Read-PlainOrPrompt $FtpPassword "FTP password" $true
|
||||||
$WinRmCredentialPass = Read-PlainOrPrompt $WinRmCredentialPass "WinRM password" -Secure
|
$WinRmCredentialPass = Read-PlainOrPrompt $WinRmCredentialPass "WinRM password" $true
|
||||||
|
|
||||||
Write-Host "1) Publishing..." -ForegroundColor Cyan
|
Write-Host "1) Publishing..." -ForegroundColor Cyan
|
||||||
New-Item -ItemType Directory -Force -Path $PublishDir | Out-Null
|
New-Item -ItemType Directory -Force -Path $PublishDir | Out-Null
|
||||||
|
|||||||
Reference in New Issue
Block a user