March 4, 2016 at 4:33 pm
Hello,
I saved the password to a file. But when I try to read it , I do not get the actual one. How to decypher the pswd. Please suggest.
Read-Host "Enter Password" -AsSecureString | ConvertFrom-SecureString | Out-File "C:\Temp\Password.txt"
$pass = Get-Content "C:\Temp\Password.txt" | ConvertTo-SecureString
$pass
Password: System.Security.SecureString
Do I need to again any of the PS function to convert to the actual value? Or, do I only need to use that as "Credential"?
$User = "abcd"
$File = "C:\Temp\Password.txt"
$MyCredential=New-Object -TypeName System.Management.Automation.PSCredential ` -ArgumentList $User, (Get-Content $File | ConvertTo-SecureString)
Thanks.
March 4, 2016 at 5:29 pm
Even could not able to pass it properly to the connection string using $bytes and username too.
$password = read-host -prompt "Enter your Password"
$secure = ConvertTo-SecureString $password -force -asPlainText
$secure
$bytes = ConvertFrom-SecureString $secure
$bytes
Thanks.
March 4, 2016 at 5:33 pm
Using this encrypted pswd, failing to connect to Oracle Instance..
$password = read-host -prompt "Enter your Password"
$secure = ConvertTo-SecureString $password -force -asPlainText
$secure
$bytes = ConvertFrom-SecureString $secure
$bytes
$username = "usr"
$tnsalias = "TNS.ORA"
$script = Get-content "D:\Powershell_Output_test\Script\Oracle_Script\select.sql"
$script
$outputfile = "D:\Powershell_Output_test\output_Oracle\sql-output.txt"
$script | sqlplus -silent $username/$bytes@$tnsalias $script | Out-File $outputfile
Thanks.
March 6, 2016 at 5:37 am
SQL-DBA-01 (3/4/2016)
Even could not able to pass it properly to the connection string using $bytes and username too.
$password = read-host -prompt "Enter your Password"
$secure = ConvertTo-SecureString $password -force -asPlainText
$secure
$bytes = ConvertFrom-SecureString $secure
$bytes
Generally use
$password = read-host -prompt "Enter your Password" -AsSecureString
To decrypt the secure string you would use
$BSTR = `
[System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($password)
$PlainPassword = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto($BSTR)
Write-Host "Password is: $($PlainPassword)"
-----------------------------------------------------------------------------------------------------------
"Ya can't make an omelette without breaking just a few eggs"
March 7, 2016 at 9:19 am
Many thanks Perry. It is working.
Thanks.
Viewing 5 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy