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
|
2020-07-01 00:43:47 +07:00
|
|
|
Choco-Install -PackageName postgresql -ArgumentList "--params", "'/Password:$pgPwd /NoPath'", "--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-25 16:20:48 +07:00
|
|
|
|
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]
|
2020-06-25 16:20:48 +07:00
|
|
|
$pgRoot = Split-Path -Path $pgPath.split('"')[5]
|
|
|
|
|
$pgData = Join-Path $pgRoot "data"
|
|
|
|
|
|
|
|
|
|
#Added PostgreSQL environment variable
|
|
|
|
|
Set-SystemVariable -SystemVariable PGBIN -Value $pgBin
|
|
|
|
|
Set-SystemVariable -SystemVariable PGROOT -Value $pgRoot
|
|
|
|
|
Set-SystemVariable -SystemVariable PGDATA -Value $pgData
|