What are the implications of running a CMD with the IIS user to execute a Powershell script in PHP?

Running a CMD with the IIS user to execute a Powershell script in PHP can pose security risks as it grants the IIS user potentially dangerous permissions. To solve this issue, it is recommended to use a more secure method such as using the PHP `exec()` function to run the Powershell script with specific permissions.

<?php

// Specify the path to the Powershell script
$psScriptPath = "C:\\path\\to\\script.ps1";

// Use the exec() function to run the Powershell script with specific permissions
exec("powershell -ExecutionPolicy Bypass -File $psScriptPath");

?>