Created
March 14, 2023 05:14
-
-
Save stknohg/4a6774208cbf9e2db6959191fcc4ac15 to your computer and use it in GitHub Desktop.
Windows環境にPostgreSQLのコマンドラインツールをインストールするスクリプト
This file contains hidden or 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
# Download Installer | |
$ProgressPreference = 'SilentlyContinue' | |
$installerUrl = 'https://get.enterprisedb.com/postgresql/postgresql-15.2-1-windows-x64.exe' | |
$installerLocalPath = Join-Path $env:TEMP 'postgresql-windows-x64.exe' | |
Invoke-WebRequest -Uri $installerUrl -OutFile $installerLocalPath | |
# Invoke Installer | |
$params = @{ | |
FilePath = $installerLocalPath # InstallBuilder | |
ArgumentList = @('--mode unattended', '--unattendedmodeui none', '--disable-components server,pgAdmin,stackbuilder') | |
Wait = $true | |
PassThru = $true | |
} | |
$proc = Start-Process @params | |
switch ($proc.ExitCode) { | |
0 { | |
# インストール成功 | |
break | |
} | |
Default { | |
# その他のエラー | |
Write-Error ("Failed to install.(Exit code={0})" -f $_) | |
break | |
} | |
} | |
# Remove Installer | |
if (Test-Path -LiteralPath $installerLocalPath) { | |
Remove-Item -LiteralPath $installerLocalPath | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment