HPE Morpheus Enterprise Software
1856275 Members
3194 Online
104111 Solutions
New Discussion

Task PowerShell script - How to use PowerShell 7.x

 
SOLVED
Go to solution
CA1239945
Occasional Contributor

Task PowerShell script - How to use PowerShell 7.x

I have a task that runs a cmdlet that requires PowerShell 7. Tasks that have the type PowerShell Script default to Windows PowerShell 5.x. How do I get Morpheus to use PowerShell 7 instead?

5 REPLIES 5
CA1239945
Occasional Contributor

Re: Task PowerShell script - How to use PowerShell 7.x

Thank you both. I was able to workaround my issue by using pwsh.exe -c parameter. I have submitted an idea as suggested. :slightly_smiling_face:

rbmorph
HPE Pro
Solution

Re: Task PowerShell script - How to use PowerShell 7.x

you could look to wrap your powershell script like this in the Morpheus powershell task

pwsh -c {$PSVersionTable}

Also I think this would be a great idea for you to raise in our ideas section. I think there should be a selection on the powershell task to run windows powershell either under powershell.exe or pwsh

tyboyd
HPE Pro

Re: Task PowerShell script - How to use PowerShell 7.x

The PowerShell task calls PowerShell.exe (version 5).

Unfortunately, I’m not aware of any method to alter this. However, it might be beneficial to suggest this as an idea for improvement! Feel free to share your idea here. Ideas - Morpheus

One way around this might be to use a file template to place the script onto the VM and start the process from PS 5 using Start-Process.

Start-Process -FilePath “pwsh.exe” -ArgumentList “-File .\PowerShellScript.ps1” -Wait

There could be a better approach out there, this is just what initially came to mind



I work at HPE
HPE Support Center offers support for your HPE services and products when and how you need it. Get started with HPE Support Center today.
[Any personal opinions expressed are mine, and not official statements on behalf of Hewlett Packard Enterprise]
Accept or Kudo
CA1239945
Occasional Contributor

Re: Task PowerShell script - How to use PowerShell 7.x

Thanks for the quick reply, I’ll give that a go.

rbmorph
HPE Pro

Re: Task PowerShell script - How to use PowerShell 7.x

you could look to wrap your powershell script like this in the Morpheus powershell task

pwsh -c {$PSVersionTable}

Also I think this would be a great idea for you to raise in our ideas section. I think there should be a selection on the powershell task to run windows powershell either under powershell.exe or pwsh