-
-
Save Eason0210/04f4ba77e617a075a8bd99b87783a70b to your computer and use it in GitHub Desktop.
PowerShell script to run psql prompting for connection details
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Write-Host "Enter connection details:" | |
$server = "localhost" | |
$server_maybe = (Read-Host -Prompt "Server [$server]") | |
If($server_maybe -ne "") { | |
$server = $server_maybe | |
} | |
$db = "postgres" | |
$db_maybe = (Read-Host -Prompt "Database [$db]") | |
If($db_maybe -ne "") { | |
$db = $db_maybe | |
} | |
$port = 5432 | |
[int]$port_maybe = (Read-Host -Prompt "Port [$port]") | |
If($port_maybe -ne "") { | |
$port = $port_maybe | |
} | |
$username = "postgres" | |
$username_maybe = (Read-Host -Prompt "Username [$username]") | |
If($username_maybe -ne "") { | |
$username = $username_maybe | |
} | |
Write-Host "Running psql" | |
Write-Host | |
psql -h $server -U $username -d $db -p $port |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment