Start a PowerShell script via a website
Tromar01
Posted messages
8
Registration date
Status
Member
Last intervention
-
Tromar01 Posted messages 8 Registration date Status Member Last intervention -
Tromar01 Posted messages 8 Registration date Status Member Last intervention -
Hello,
I often work on the road or using remote connections at client sites (I am an IT technician), and to save time, I create PowerShell scripts with a GUI to manage different command lines, download files, etc., to save time. I was wondering if it would be possible to integrate a password-protected link on my website that would allow me to execute my script without having to download it each time on every PC, but that could still communicate with the user's environment.
I am almost certain it can't be done, but before I officially say it's impossible, I would prefer to ask the question.
P.S.: I am open to any comments that could help me achieve the final result, even with a different type of programming.
Thank you :)
Configuration: Windows / Chrome 96.0.4664.110
I often work on the road or using remote connections at client sites (I am an IT technician), and to save time, I create PowerShell scripts with a GUI to manage different command lines, download files, etc., to save time. I was wondering if it would be possible to integrate a password-protected link on my website that would allow me to execute my script without having to download it each time on every PC, but that could still communicate with the user's environment.
I am almost certain it can't be done, but before I officially say it's impossible, I would prefer to ask the question.
P.S.: I am open to any comments that could help me achieve the final result, even with a different type of programming.
Thank you :)
Configuration: Windows / Chrome 96.0.4664.110
1 answer
Hello,
No, in fact it's impossible for the web browser to be allowed to run a program on its own, and for an obvious reason. Imagine the risks if simply displaying a site could launch a program on the computer. Not to mention viruses, it's a gateway to all dangers, and just viewing a webpage could simply erase the hard drive or carry out malicious actions, install any unwanted software, even more so if it involves shell commands that can do quite a lot.
However, I do not understand this:
"to execute my script without having to download it"
Well, for the part about forcibly executing a program (regardless of the nature of the program), I responded, but I do not understand what you mean by not having to "download". You need to review how a network works, especially the WWW service of the Internet. Without downloading (uploading and downloading) = no network and even less a website. Downloading means loading from a distance, for a network it's therefore making a resource available (for example, the files of a website), the files do not appear by magic but are broadcast over the network. This is even what defines a network: sharing content (therefore loading files on one computer or another on the network from a distance).
The type of programming is therefore not really at issue, but it's the very principle you are asking for that is impossible due to the nature of using the WWW.
Other solutions:
You can make the file available on the network for download and then execute it on the client computer, but in this case, someone must be physically present (or ask the client to download the program file) to then execute it.
With a good information system (i.e.: a database and its management program), you can easily update it.
Use a network that allows what you want, therefore a network where you are the administrator and can do anything on the computers in the network. There are also software that allows this and consists of taking control of the computers on the network (= administering them).
I am also thinking about Linux via SSH (a type of secure network connection) and using BASHR (the equivalent of Windows SHELL but for Linux), which seems much more flexible for this type of use or at least more functional it seems. Of course, this is only possible with computers running Linux, so I only suggest this solution as a last resort.
Another conceivable possibility depends on the functionalities you want to perform. If it is just about downloading files, this can simply go through WWW using a link (HTML), for example:
https://www.w3schools.com/TAGS/att_a_download.asp
For what the other command lines should do, it depends on the command lines in question and obviously the establishment of an information system over the network: a database and its program that provide the page if necessary. If, for example, you need to manage data, this solution remains the most sustainable (automation of processes to provide this data and modify/add it if necessary).
But indeed, to intervene on the contents of a computer (other than downloading a file and using the browser's cache or other temporary storage but limited by the browser), the mentioned security restrictions apply, so you cannot create or modify directories and their contents in this way. No modification or direct addition of a program (when a program file is downloaded, there is a warning during its download and then a warning when the file is launched for execution).
However, it seems quite simple to me to indicate to your clients how to click on a link to download the script file and indicate how to execute it via command line (and indicate to accept when there is a warning). But that strays from the initial request.
There are plenty of other solutions, but as mentioned, it all depends on what you want to do (and the working time/importance you attach to the desired result).
Some possible examples:
https://suttonedfoundation.org/fr/90128-how-to-execute-bash-with-ssh-connection-bash-unix-ssh.html
https://blog.ronanlefichant.fr/2019/07/commande-powershell-java.html
No, in fact it's impossible for the web browser to be allowed to run a program on its own, and for an obvious reason. Imagine the risks if simply displaying a site could launch a program on the computer. Not to mention viruses, it's a gateway to all dangers, and just viewing a webpage could simply erase the hard drive or carry out malicious actions, install any unwanted software, even more so if it involves shell commands that can do quite a lot.
However, I do not understand this:
"to execute my script without having to download it"
Well, for the part about forcibly executing a program (regardless of the nature of the program), I responded, but I do not understand what you mean by not having to "download". You need to review how a network works, especially the WWW service of the Internet. Without downloading (uploading and downloading) = no network and even less a website. Downloading means loading from a distance, for a network it's therefore making a resource available (for example, the files of a website), the files do not appear by magic but are broadcast over the network. This is even what defines a network: sharing content (therefore loading files on one computer or another on the network from a distance).
The type of programming is therefore not really at issue, but it's the very principle you are asking for that is impossible due to the nature of using the WWW.
Other solutions:
You can make the file available on the network for download and then execute it on the client computer, but in this case, someone must be physically present (or ask the client to download the program file) to then execute it.
With a good information system (i.e.: a database and its management program), you can easily update it.
Use a network that allows what you want, therefore a network where you are the administrator and can do anything on the computers in the network. There are also software that allows this and consists of taking control of the computers on the network (= administering them).
I am also thinking about Linux via SSH (a type of secure network connection) and using BASHR (the equivalent of Windows SHELL but for Linux), which seems much more flexible for this type of use or at least more functional it seems. Of course, this is only possible with computers running Linux, so I only suggest this solution as a last resort.
Another conceivable possibility depends on the functionalities you want to perform. If it is just about downloading files, this can simply go through WWW using a link (HTML), for example:
https://www.w3schools.com/TAGS/att_a_download.asp
For what the other command lines should do, it depends on the command lines in question and obviously the establishment of an information system over the network: a database and its program that provide the page if necessary. If, for example, you need to manage data, this solution remains the most sustainable (automation of processes to provide this data and modify/add it if necessary).
But indeed, to intervene on the contents of a computer (other than downloading a file and using the browser's cache or other temporary storage but limited by the browser), the mentioned security restrictions apply, so you cannot create or modify directories and their contents in this way. No modification or direct addition of a program (when a program file is downloaded, there is a warning during its download and then a warning when the file is launched for execution).
However, it seems quite simple to me to indicate to your clients how to click on a link to download the script file and indicate how to execute it via command line (and indicate to accept when there is a warning). But that strays from the initial request.
There are plenty of other solutions, but as mentioned, it all depends on what you want to do (and the working time/importance you attach to the desired result).
Some possible examples:
https://suttonedfoundation.org/fr/90128-how-to-execute-bash-with-ssh-connection-bash-unix-ssh.html
https://blog.ronanlefichant.fr/2019/07/commande-powershell-java.html
I was already using my website to upload my files to the clients' computers as needed, but I just wanted to find a solution to avoid cluttering their PCs with files they wouldn't use and that I delete every time at the end of the session.
I converted my .ps1 file to .exe using PS1 to EXE, which works very well; it allows temporary files to be added when the executable file is opened and deleted when closed, but the file itself remains present upon closing. Another issue with this method is that some antivirus programs block the file, and I haven't yet figured out how to make it "safe" for antivirus software :/
"With a good information system (i.e.: a database and its management program), you can easily update it." I do believe this could help me; I should do my homework on that ;)
"There are plenty of other solutions, but as mentioned, it all depends on what you want to do (and on the amount of work/importance you give to the desired result)" Ah!! I am persistent; I sometimes spend sleepless nights when I can't get something to work until it finally does, haha.
Thanks again for your reply :)