Run powershell command from PHP

Viewed 31

I am developing a web page to manage domain users from the web. Now I'm with the part of unlocking users, but I can't concatenate the values

It works:

echo Shell_Exec ('powershell.exe -executionpolicy bypass -NoProfile -Command "Unlock-ADAccount -identity User001| ConvertTo-Html"');

Not works:

echo Shell_Exec ('powershell.exe -executionpolicy bypass -NoProfile -Command "Unlock-ADAccount -identity $user| ConvertTo-Html"');

In the command if I put the name of a user it works, but I need to put a variable. in $user I collect the value that is put in an html form.

I was trying to put Unlock-ADAccount -identity ."$user."| ConvertTo-Html"'); but it does not work.

I don't know if it can really do what I want.

Help on how to continue with my project or suggestions

0 Answers
Related