• Welcome to Support Forum: Get Support for Patch My PC Products and Services.
 

Powershell pre/post-script - Is the interpreter always Windows Powershell?

Started by PS_Alex, August 23, 2023, 03:44:57 PM

Previous topic - Next topic

PS_Alex

Hello!

Quick question: for ".ps1" pre-scripts and post-scripts, is the interpreter always Windows Powershell? Looking at PatchMyPC-ScriptRunner.log, I can observe that:
<...>
Running script preinstall.ps1 ScriptRunner 2023-08-23 2:50:30 PM 1 (0x0001)
Running PowerShell Script. ScriptRunner 2023-08-23 2:50:30 PM 1 (0x0001)
Running C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -file "preinstall.ps1" ScriptRunner 2023-08-23 2:50:30 PM 1 (0x0001)
Exiting With code: 0 ScriptRunner 2023-08-23 2:50:31 PM 1 (0x0001)
<...>

I have set nowhere which version of Powershell to prefer, so I'm assuming ScriptRunner is responsible of selecting the appropriate one. I'm wondering if it will always default to Windows Powershell, or if it might at some point detect that PS7 is present and use it, or if it looks at a favorite interpreter somewhere, etc. ?

Thanks!

Ben Whitmore (Patch My PC)

Hey PS_Alex

We are explicitly calling Windows PowerShell to run our pre and post scripts.

(_sysPath, "WindowsPowerShell\v1.0\powershell.exe")

We dont have any plans to consider other interpreters at this time. If you think that would be beneficial, we do have an ideas page where you can drop that suggestion in with a use case :)

https://ideas.patchmypc.com/

Hope that helps!

PS_Alex

Thanks Ben!

We're evaluating deploying Powershell 7 on all of our devices, so we were simply wondering if that could have adverse effects on patches installation which have a pre- or post-script. Based on your answer, that won't cause any issue.