running powershell on php that store in winscp
hi guys, i am new to powershell and also winscp. the problem that i currently stuck are how the php script run the ps1 script on the winscp . both file are save in the same directory.
this is my php script
Try {
#Store all processes in $MyProcesses
$Processes = Get-Process
#Convert $Processes in HTML
$MyHTMLCode = $Processes | ConvertToHTML
#Return the HTML code to the PHP Page
Return $MyHTMLCode
}
Catch {
#Something went wrong
Return "Oops: Something went wrong.<br />$($_.Exception.Message)<br />"
}
this is my php script
<?PHP echo Shell_Exec ('powershell.exe -executionpolicy bypass -NoProfile -File ".\MyPSscript.ps1"'); ?> this is my powershell script
Try {
#Store all processes in $MyProcesses
$Processes = Get-Process
#Convert $Processes in HTML
$MyHTMLCode = $Processes | ConvertToHTML
#Return the HTML code to the PHP Page
Return $MyHTMLCode
}
Catch {
#Something went wrong
Return "Oops: Something went wrong.<br />$($_.Exception.Message)<br />"
}