I am automating a database reload as part of a test script. To my dismay, pg_restore.exe appears to only return $null. Even when deliberately mangling the file name, I get a $null back (although it prints a message to the screen). However a screen print doesn't do the script any good.
The line in the PowerShell script, which works, other than a complete lack of feedback...
$PGResult = &"C:\Program Files\PostgreSQL\16\bin\pg_restore.exe" --clean --dbname=postgresql://:@localhost:/<target_database> $DB_Filename
The $DB_Filename changes per run but the rest of the <> tags are a fixed part of the script.
Any idea how to get some kind of return code from pg_restore.exe so that the script knows if the database was successfully restored or not?