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

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

    Have you removed all other versions?

  • 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.

Reply
  • 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.

Children
  • 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