79488089

Date: 2025-03-06 02:18:41
Score: 1.5
Natty:
Report link

Since I couldn't call PS 7.4 executable directly to execute a script, I implemented a convoluted work-around by calling PS5 script that would call PS7.4 to execute the script I want. To get the output of the script, I redirect it to a temp file and then read it in php.

I will use this setup temporarily until I can figure out why I can't call PS 7.4 executable directly from php.

php code

shell_exec('powershell.exe -File C:\inetpub\ps5-calling7.ps1');
$output = "C:\\inetpub\\env_output.tmp";

ps5-calling7.ps1

Start-Process pwsh.exe -ArgumentList "C:\inetpub\env_output.ps1" -wait -RedirectStandardOutput "env_output.tmp";
Reasons:
  • RegEx Blacklisted phrase (1): I want
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: Singsiblaw