I tried using @Mathias R. Jessens answer above but it wouldn't work for me, the reason was the $PhpArgs = '-f "{0}"' -f $PhpFile
contained the first '-f'
part. So using his answer (and what worked for me was)
# Set up references to executable and script
$PhpExe = "C:\path\to\php\install\dir\php.exe"
$PhpFile = "C:\path\to\script.php"
# Create arguments from Script location
# usually php.exe is invoked from console like:
# php.exe -f "C:\path\myscript.php"
$PhpArgs = '"{0}"' -f $PhpFile //Changed this line!
# Invoke, using the call operator
$PhpOutput = & $PhpExe $PhpArgs
Hope it helps someone :)