Important Notice: On February 29th, this community was put into read-only mode. All existing posts will remain but customers are unable to add new posts or comment on existing. Please feel to join our Community Discord for any questions and discussions.

Run Command powershell version

When I "run a command" from PDQ Inventory and set to use powershell on windows 2012R2 it seems to default to powershell version 4, is there anyway to set the version it uses ? As powershell 7 is installed.

 

Can Powershell 4 even be removed from windows 2012R2 ?

0

Comments

4 comments
Date Votes
  • PowerShell Core (currently version 7) is a different executable, pwsh.exe vs powershell.exe. Deploy and Inventory do not have native integration with PowerShell Core. You would have to call pwsh.exe in your script.

    PowerShell 4 cannot be removed, but it can be updated to 5.1.

    0
  • Thanks for the feedback and hints 

    0
  • Is PDQ going to adopt PS7 at some point? Can we change the default %systemroot%\System32\WindowsPowerShell\V1.0\PowerShell.exe -NoLogo -NonInteractive -NoProfile -ExecutionPolicy Bypass command line when on a powershell step with out clicking custom and modifying every package?

    0
  • Yeah...that's super annoying.

    Changing it to "C:\Program Files\PowerShell\7\pwsh.exe" -NoLogo -NonInteractive -NoProfile -ExecutionPolicy Bypass

    Causes this in the log files...

    [31;1mGet-Service: [0mC:\Windows\AdminArsenal\PDQDeployRunner\service-1\exec\user.ps1:1[0m
    [31;1m[0m[36;1mLine |[0m
    [31;1m[0m[36;1m[36;1m   1 | [0m [36;1mget-service "*screenconnect*"[0m | remove-service[0m
    [31;1m[0m[36;1m[36;1m[0m[36;1m[0m[36;1m     | [31;1m ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~[0m
    [31;1m[0m[36;1m[36;1m[0m[36;1m[0m[36;1m[31;1m[31;1m[36;1m     | [31;1mService 'MyServiceNameRedacted[0m
    [31;1m[0m[36;1m[36;1m[0m[36;1m[0m[36;1m[31;1m[31;1m[36;1m[31;1m[36;1m     | [31;1m(d125c445-7374-479b-92dc-d5be24fdfb80))' cannot be queried due to the following error:[0m
    [31;1mException: [0mC:\Windows\AdminArsenal\PDQDeployRunner\service-1\exec\Error Handling Wrapper.ps1:58[0m
    [31;1m[0m[36;1mLine |[0m
    [31;1m[0m[36;1m[36;1m  58 | [0m     [36;1mThrow $_.Exception.ErrorRecord[0m
    [31;1m[0m[36;1m[36;1m[0m[36;1m[0m[36;1m     | [31;1m     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~[0m
    [31;1m[0m[36;1m[36;1m[0m[36;1m[0m[36;1m[31;1m[31;1m[36;1m     | [31;1mScriptHalted[0m

    Unfortunately Remove-Service isn't available until PowerShell 6....which also doesn't appear to be natively supported.

    0