none
Passworteingabe löschen RRS feed

  • Frage

  • Hallo!

    Ich habe ein Skript welches eine Passwortdatei erstellt. Jedoch kann über die history das Passwort gelesen werden.

    Nun wollte ich die History bzw. die letzten beiden eingaben mit dem Befehl Clear-History -Count 2 löschen lassen. jedoch wird die History nicht gelöscht. Was mach ich falsch bzw. was muss ich anders machen?

    $colForeGround_before = $Host.UI.RawUI.ForegroundColor
    $colBackGround_before = $Host.UI.RawUI.BackgroundColor
    Write-Host "###############Erstellen einer verschlüsselten Passwortdatei#################"
    Write-Host ""
    write-host "Bitte das zu verschlüsselnde Passwort eingeben"
    $Host.UI.RawUI.ForegroundColor = [System.ConsoleColor]::Gray
    $Host.UI.RawUI.BackgroundColor = [System.ConsoleColor]::Gray 
    $password=read-host
    $Host.UI.RawUI.ForegroundColor = $colForeGround_before
    $Host.UI.RawUI.BackgroundColor = $colBackGround_before
    $path = read-host "Bitte den Speicherpfad der Passwortdatei angeben"
    Clear-History -Count 2
    ConvertTo-SecureString $password -AsPlainText -Force | ConvertFrom-SecureString | Out-File -FilePath $path

    Grüße Georg

    Dienstag, 23. Oktober 2012 09:19

Antworten

  • Ich habe das hier mal für SQL gebraucht, und es funktioniert:

    $sqlpw = Read-Host "Enter SQL Password" -AsSecureString #Speichert das eingegebene Passwort als SecureString (kann nicht gelesen werden und wird in der Konsole nicht gepsichert)
    $sqlpwsecure = `
        [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($sqlpw) #Da System.String nicht sehr sicher ist und öfters Probleme verursacht, wird hier das Passwort verstärkt gesichert.
    $HiddenPW = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto($sqlpwsecure)


    The following is my signature:

    Powershell Programmer & Advanced Lua Programmer

    Location: Switzerland

    Beside that, whenever you see a reply, you think is helpful, click "Alternate TextVote As Helpful"! And whenever you see a reply being an answer to the mainquestion of the thread, click "Alternate TextMark As Answer" (if you opened the thread).

    Please contact me, before reporting me, thank you.

    [string](0..21|%{[char][int]([int]("{0:d}" -f 0x28)+('577076797174-87661607769657424-8687168065964').substring(($_*2),2))})-replace' '

    • Als Antwort markiert nieselfriem Dienstag, 23. Oktober 2012 12:16
    Dienstag, 23. Oktober 2012 09:25