【发布时间】:2018-06-18 05:46:22
【问题描述】:
如何在PowerShell中设置环境变量的值并在一行中执行命令?
我有这个:
PGPASSWORD=db_pass psql -U db_user -d db_name -a -h localhost -f some.sql
它在 Linux 中运行良好。
如何将上面的内容转换为适用于 Windows Server 2012 - Windows 10 的 PowerShell 命令?
我试过了:
SET "PGPASSWORD=db_pass" & "C:\Program Files (x86)\PostgreSQL\9.4\bin\psql.exe" -U postgres -a -d db_name -h localhost -f some.sql
我收到错误:“& 保留供将来使用...” - Windows 2012。
【问题讨论】:
标签: bash powershell environment-variables