I have a HTML form with some PHP to execute a PowerShell script.
All works fine, except for the textarea input field. If I do a single line of text in the textarea box, it works OK and launches the PowerShell script. If I insert multiples lines of text, including carriage returns, it only will take the first word/line and cut the rest.
Here is the command that launches the PowerShell script:
with one word in the textarea box:
powershell -command file.ps1 -textarea 'test'
with multiple words in the box
powershell -command file.ps1 -textarea 'firstword
As shown above, when multiple lines are in the TextArea field, it will strip it and only send the first word. This causes the PowerShell script to fail as the terminator is missing.
Any ideas?
Here is the code:
if($isValid) {
$customerid = $_POST["DLState"];
$changesubject = $_POST['subject'];
$starttime = $_POST['starttime'];
$endtime = $_POST['endtime'];
$changedetails = $_POST['details'];
$psScriptPath = "*****";
$query = shell_exec("powershell -command $psScriptPath -username '$user' -subject '$changesubject' -orgid '$customerid' -textarea '$changedetails' -edt '$endtime' -sdt '$starttime' < NUL");
}
HTML text area tag
<textarea id="txtarea" name="details" cols="40" rows="6"></textarea>