Insert data to PostgreSQL table with powershell via php file

Short information. I have a script that creates database backup, then creates random password, zips that file and protects it with that random password. Currently I've made it so that it will export that password to .csv file and eventually it will upload those files to FTP but that does not add any security because protected file and password are at the same place. What I want to do is instead of exporting that random pass to .csv file, is to submit that password to a .php via URL or something that eventually would POST that pass to a postgreSQL database table along with backup date and database name. I already established a connection from PHP file to a database but how can I POST that info with powershell to database? I want to use .php because then I can use some kind of URL instead of putting all database connection info in a .PS1 file..

Answer

Solution:

You can use the Invoke-WebRequest cmdlet to submit HTTP requests:

$password = 'sUp3rs3c3t'
Invoke-WebRequest -Uri 'https://my.domain.tld/api/addBackupPassword.php' -Method POST -Body $(@{password=$password}|ConvertTo-Json)

Source