I am trying to build a simple script that outputs a query to a csv in powershell. However, it keeps returning the following error:
psql: fe_sendauth: no password supplied
I tried exposing the password as this will be a safe environment, but have seen suggestions to use pgpass but no real explanation on how to implement.
Set-Location 'E:\Program Files\PostgreSQL\9.1\bin\';
SET 'PGPASSWORD = myPwd';
.\psql -U postgres -w MyDatabase
copy {'SELECT * FROM table';} TO 'C:\Users\e\Desktop\test1.csv' CSV DELIMITER ',';