Right click on selected object, starting Powershell script

Hello; recently, tried to use Powershell to automate some tasks, must say that it’s working great, it’s flexible, sometimes having capabilities which are really amazing.
One of scripts is prepared to run application with specific word as parameter. It is, actually making some further steps, controlling some environment variables at Windows, and using initial args parameter at the first line, as input, which is being used in filtering data later.
The word, string, may be added using different ways, for example, by running the Powershell script from command line, with the additional string as parameter.
What I would need is the possibility to take the parameter string from, for example, any browser (IE, FF, Edge) text, by selecting the text at the browser window (single word), doing right mouse click to the selected word, choosing proper additional menu option from the context menu there, which would represent the script ps1 Powershell file. Selected word will be used as string parameter args, script will first check if it’s empty string, if it is proper string and then run the further steps.
Seems that there will be a need to use Registry editor to add additional Powershell keys there.
Please, anybody has experience with this? Thanks a lot.

aldowski,
Welcome to the forum. :wave:t4:

An easy to accomplish workaround could be to simply copy the word in your browser and use PowerShells ability to access the clipboard with

To make it easier to access you could set up a keyboard shortcut to fire up the script.

Thanks for the reply.
Yes, already have that working properly, as after string is being selected and copied, on the Desktop, I created Shortcut which is, when doubleclicked, starting the Powershell script and taking the Clipboard content, and do all those next steps.
Using that solution for more occasions, works well.
I just wanted to improve this, to have right click context menu, which may be started on any window, after some string is being selected and captured into Clipboard. Must say that this script has more tasks inside, including the checking of few existing processes in RAM (Powershell does fantastic work on this). I saw few tutorials which are dealing with similar problems, unfortunately, more with specific applications like Windows Explorer, but I am trying to find some Registry steps, to achieve possibility for this to work in any browser / text editor, Visio diagram, for example.
Browsers do have some right click menu option like “Search by Bing” or “Search by Google”, when word (string) is chosen there, at the Page body, I would like to have next option, below, similar to it, like “Run Powershell with the chosen word / string”.
There must be possibility for that, I saw recently that Powershell really is very powerful (as named). Of course, there can be something to do (add) into Registry as well.

I know what you mean but this is not a PowerShell topic anymore. :wink: You may be better off in a general Windows forum or in a browser forum.

Likely not going to solve your problem, but if you own the web page, you can alter the context menus via JavaScript. Now, launching a script from there on the local file system is going to be a real challenge and likely not possible. I think you should stick with Olaf’s suggestion.

You could also download the source code for FF and get it done that way :slight_smile: As Olaf stated, this is not really PowerShell any more.

I started using the Powershell as it has some similarity to Expect in Bash. Years ago, created lots of scripts in it, interactive and great for step - by - step checking details, when doing some procedures.
I tried to resolve this issue on the page itself, there is possibility using Sharepoint tools (unfortunately some of those not in use anymore) and / or Power Apps; found that it is possible but not universal.
What I will do now, as I have created almost everything else, simply, first step, select word / string, second Ctrl + C to it to put it to Clipboard, then, third step to use prepared Shortcut at Desktop (which will run the Powershell .ps1 script) by clicking Ctrl + Alt + C (as those keyboard shortcuts may be started just from Desktop and must have Ctrl and Alt in the combination with letter), so the selected and copied word / string will be immediately processed inside the Powershell script.
I had the clipboard management in previous scripts as well, Powershell is managing it best possible way in both directions - not only the clipboard content may be copied to variable, the opposite direction is also possible, which is sometimes useful.
Thanks for replies, I just described the way I’ll use to resolve this, maybe it will be helpful for someone else.