Set Active Roles (ARS) Scheduled (PowerShell) Script Modules to Execute in PWSH.exe (v6+) vs POWERSHELL.exe

How can I explicitly instruct ARS to execute scripts in PowerShell v7

  • Do you have Powershell 7 installed on your Active Roles server(s)?

    Have you removed all other versions?

  • I was just checking the Release Notes and interestingly, the highest version I could find in there is 5.1

  • I think you've answered me indirectly - there must not be a way to specify the environment to launch a script module in.

    It looks like if I want to utilize things like "foreach-object -parallel" I guess I will simply have to make a stub loading script that calls PWSH.exe itself.

    but for thoroughness:

    Yes, PowerShell 7.1.2 is installed on the Active Roles server.

    And as for the other versions, the server has never had Core 6.x or any other version of 7.

    but if you mean the native Windows PowerShell 5.1 - that is of course still present, running ARS script modules currently, and cannot be disabled / removed.

  • Thanks.

    My (cautionary) point about the highest version is that 5.1 is the highest supported PoSh version (as far as I can tell).  So if something AR-specific you are doing doesn't work in v 7.1.2, or worse, creates some kind of instability in the service then you are out of luck.

    The PoSh nerd in me is intrigued with the use case you are trying to tackle with the for-each-object -parallel loop construct.  Slight smile

  • Currently Active Roles uses Windows PowerShell for its PowerShell runtime environment. There is no way to tell it to use the newer PowerShell in its place (good feature request idea though).

    With that said, you definitely can use PowerShell 6/7 to run the Active Roles Management Shell cmdlets outside of Active Roles. In fact, they actually run significantly faster when ran in a PowerShell 7 terminal. I haven’t tested every cmdlet with every parameter though so I would not be able to confidently say they will all work. I've passed this information onto some folks to see if we can get this tested to potentially list it as supported (still referring to outside the Active Roles runtime environment). I wouldn't be able to provide any sort of ETA on that as it would have to be properly reviewed and placed in the appropriate priority queue to get done.

    You could try using the start-process cmdlet to launch PWSH.exe with an external script file. You won't have the amount of integration as you do with a script module but it should work. Unfortunately I'm not in a position to test it at the moment so you'd have to test that on your own.