Post a reply

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

zayden

Re: running powershell on php that store in winscp

martin wrote:

I do not see what does your question have to do with WinSCP.

sry ya , first time using this forum . the question that i want to ask is , it's possible to let the php.file that i store on winscp to call the powershell script on local C: drive ?
martin

Re: running powershell on php that store in winscp

I do not see what does your question have to do with WinSCP.
normanong

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
<?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 />"
}