I'm writing a script right now but I can't figure out why this adding to the script makes my -AsSecureString echo in the finished result while compiled to an CMD/window (.*Exe) with ISEsteroids.
I am using Read-Host
to use above and hide password written inside script. And while running the code in editor it works wonderful. But while compiled using ISEsteroids to executable my script runs and then at the end echos the password 3 times in plain text... like this(images)
im using this to add the "run again" boxes and script in between.
$choices = [System.Management.Automation.Host.ChoiceDescription[]] @("&Yes","&No")
while ( $true ) {
Script here:
$Host.UI.RawUI.WindowTitle = $PSScriptRoot
$choice = $Host.UI.PromptForChoice("Run again","",$choices,0)
if ( $choice -ne 0 ) {
break
}
}
ISE output:
Output from executable:
UPDATE - SOLVED got help from @mklement0! this solved the issue.
while ([Console]::KeyAvailable) { $null = [Console]::ReadKey($true) }