Search code examples
postgresqlpowershellpsql

Is it possible to call psql with an password encrypted in PowerShell?


Is it possible to call psql with passwords encrypted in Powershell?

There are many documents that describe hiding passwords with Get-Credential, ConvertFrom-SecureString and ConvertTo-SecureString. Even though that's not a perfect solution, I'd like to try that for on PostgreSQL passwords in a PowerShell script.

But, psql is not accepting the password passed by ConvertTo-SecureString.

Is there a way to do it?


Solution

  • Actually, below commands worked after upgrading to PowerShell 7. It returned the original password in plain text.

    ConvertTo-SecureString | ConvertFrom-SecureString -AsPlainText