Search the Community
Showing results for tags 'php & powershell'.
-
Hello: I have been developing a web tool to perform basic maintenance to 100's of MacOS units, which at this point it works fantastic. Now I am faced with the task of integrating 350 units in windows. The need is to send commands through powershell. I have tried to use system(), exec(), shell_exec() and have not been successful. The drop that spilled the cup this morning was... I sent a "reboot -r -t 01" command to a windows server hoping that it would perform a PSSession to a different non critical server, but to my surprise... You guessed it... I rebooted a production Server ... I am new to Powershell so I am not as fluent on it... But I am sure that it does not matter if you use a MacOS or a Windows or a Unix PHP server... the commands should be sent the same way and not platform dependent... Correct? Or is it that PHP needs a Powershell module installed such as ssh2?? As an example... How can I send a command to a Windows Unit from a php command? Let's say: shell_exec('powershell"Invoke-Command -ComputerName WindowsUnit1 -ScriptBlock { Get-Service dhcp } -Credential $Credentials"'); I have been getting the server to hang when trying to send this through a Windows based PHP server. I have added the "< NUL 2>&1" option at the end to get some feedback as well. On a MacOS based PHP server, the $credentials variable is unset, so.. in order for me to set the credentials, how can I do so? I hope someone here has faced this before and can shed some light my way. Thanks Hiroshi T
- 3 replies
-
- powershell
- macos & powershell
- (and 2 more)