Event Hub Agent - How do (or Can) you specify the PowerShell version (Environment) to use?

Interesting. So, yes, what you just provided does work. What I had previously tried, that does NOT work, is that I had been sending it Invoke-WebRequest as -Data with the Content parameter, so the agent was then dumping that into a temporary .ps1 file that it would execute. It’s that execution that runs as PS5.

Sending it the Invoke-WebRequest via -Command instead of via -Data does allow it to work (as you showed).

I think part of the issue was that there’s not very much documentation about how to configure the agent or how to send it instructions in each scenario, so I was basing the design around what IS listed on the documentation site and what @parzog had shared here.

So, if what I initially asked for were an option - to tell the agent to explicitly use PS7 when executing scripts - it would allow both methods to work.