I am trying to develop a PHP application which executes a Powershell command via shell_exec().
However Once the command is executed, it doesn't work because it says it doesn't have permission. Any ideas what I have to do?
My code:
$psscriptpath = "C:\inetpub\htdocs\school_panel\scripts\change.ps1";
$cmdlet = "powershell.exe -executionpolicy remotesigned -File {$psscriptpath} -username {$username} -password {$password} < NUL";
echo $cmdlet;
$output = shell_exec($cmdlet);
echo $output;
There error message:
powershell.exe -executionpolicy remotesigned -File C:\inetpub\htdocs\school_panel\scripts\change.ps1 -username testingacount -password TestingTest321 < NULSet-ADAccountPassword : Access is denied
At C:\inetpub\htdocs\school_panel\scripts\change.ps1:18 char:22
+ Set-ADAccountPassword <<<< $username -NewPassword $newpwd -Reset
+ CategoryInfo : PermissionDenied: (testingacount:ADAccount) [Set-ADAccountPassword], UnauthorizedAccessException
+ FullyQualifiedErrorId : Access is denied,Microsoft.ActiveDirectory.Management.Commands.SetADAccountPassword
What I have already tried:
- Set execution policy to unrestricted on both versions of powershell
- Give full permissions to IUSER for CMD, Powershell, PHP-cgi.exe, PHP.exe and the folder containing the website
- Rearranging and doing variety of changes with code.