Quantcast
Channel: Windows PowerShell Forum
Viewing all articles
Browse latest Browse all 2562

Running Powershell Script from PHP

$
0
0
Hi, 

I am trying to run a Powershell script from PHP using Apache on Windows Server 2008. I am using the following code to launch the powershell script: 

shell_exec('powershell.exe -command C:\PSscripts\helloworld.ps1')

Unfortunately I cannot get the script to run at all. I keep getting the error message in the apache log file:

File C:\PSscripts\helloworld.ps1 cannot be loaded because the execution of scripts is disabled on this system. 

I have used the "Set-ExecutionPolicy" command to set the policy to Unrestricted and the Apache service is running as Administrator but I can't for the life of me get it to run the Powershell script. 

Running the script directly from Powershell works fine.

Any help would be fantastic! 
Thanks.

Viewing all articles
Browse latest Browse all 2562

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>