2020-06-02 19:52:42 +07:00
|
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
|
|
|
|
|
|
#Define user and password for PostgreSQL database
|
2020-06-03 17:35:03 +03:00
|
|
|
$pgUser = "postgres"
|
|
|
|
|
$pgPwd = "root"
|
2020-06-02 19:52:42 +07:00
|
|
|
|
|
|
|
|
#Prepare environment variable for validation
|
2020-06-03 17:35:03 +03:00
|
|
|
Set-SystemVariable -SystemVariable PGUSER -Value $pgUser
|
|
|
|
|
Set-SystemVariable -SystemVariable PGPASSWORD -Value $pgPwd
|
2020-06-02 19:52:42 +07:00
|
|
|
|
2020-06-03 17:35:03 +03:00
|
|
|
#Install latest PostgreSQL
|
|
|
|
|
Choco-Install -PackageName postgresql -ArgumentList "--params", "/Password:$pgPwd", "--params-global", "--debug", "--verbose"
|
2020-06-02 19:52:42 +07:00
|
|
|
|
|
|
|
|
#Get Path to pg_ctl.exe
|
2020-06-03 17:35:03 +03:00
|
|
|
$pgPath = (Get-CimInstance Win32_Service -Filter "Name LIKE 'postgresql-%'").PathName
|
2020-06-02 19:52:42 +07:00
|
|
|
#Parse output of command above to obtain pure path
|
2020-06-03 17:35:03 +03:00
|
|
|
$pgBin = Split-Path -Path $pgPath.split('"')[1]
|
|
|
|
|
#Added PostgreSQL bin path into PATH variable
|
|
|
|
|
Add-MachinePathItem $pgBin
|