How to inject script from Powershell/CMD to launch with firefox?

I want to launch a webpage from firefox and then run a script after the page is loaded from powershell

my powershell script something like

start-process firefox -argumentlist “https://www.bbc.com”, “-runscriptafterpageload funcAfterLoad();”

Is it possible?

For the most reliable results, you probably want to use something like WebDriver which is designed for these types of scenarios. https://www.selenium.dev/documentation/webdriver/browser_manipulation/

Another strategy would be to write a WebExtension that runs your script on the matching URLs and then you can start browser with a specific URL from command line.

I’m not aware of any tricks from pure command line that still work as most have been phased out in favour of more standard and cross-browser solutions.

i forgot to say it’s my company computer.
i can’t install anything to it
but i can choose firefox, chrome, IE or edge
so there is no way to do it huh?

If you can still add browser addons, you can try something like greasemonkey https://addons.mozilla.org/en-CA/firefox/addon/greasemonkey/ .

Historically, one could pass javascript: urls to command line, but I think all the browsers have been phasing that out as being too much of a security risk.