Wir versuchen, ein Benutzerkennwort in der Registrierung als sichere Zeichenfolge zu speichern, aber wir scheinen keine Möglichkeit zu finden, es wieder in Nur-Text umzuwandeln. Ist das mit SecureString möglich?Powershell SecureString Verschlüsseln/Entschlüsseln im Nur-Text-Format funktioniert nicht
Hier ist die einfache Testskript wir versuchen, zu verwenden ...
Write-Host "Test Start..."
$PlainPassword = "@SomethingStupid" | ConvertTo-SecureString -AsPlainText -Force
$BSTR = ` [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($PlainPassword)
$PlainPassword = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto($BSTR)
Write-Host "Password is: " $PlainPassword
Read-Host
Dies ist der Fehler, den wir sind ...
The term ' [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR'
is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At C:\test.ps1:4 char:71
+ $BSTR = ` [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR
<<<< ($PlainPassword)
+ CategoryInfo : ObjectNotFound: (
[System.Runtim...ureStringToBSTR:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Cannot find an overload for "PtrToStringAuto" and the argument count: "1".
At C:\test.ps1:5 char:75
+ $PlainPassword =
[System.Runtime.InteropServices.Marshal]::PtrToStringAuto <<<< ($BSTR)
+ CategoryInfo : NotSpecified: (:) [], MethodException
+ FullyQualifiedErrorId : MethodCountCouldNotFindBest
versuchen, ohne die $ BTSR Linie mit dem Rücken tick Einwickeln –
mir einen Syntaxfehler geben ... „Unexpected Token“ – devfunkd
Ok, versuchen Sie, den Klartext tatsächlich in eine eigene String-Variable zu setzen, wie in dem Artikel, von dem ich glaube, dass Sie ihn angesehen haben - http://social.technet.microsoft.com/wiki/contents/articles/4546.working-with-passwords -secure-strings-and-credentials-in-windows-powershell.aspx –