azure-powershell icon indicating copy to clipboard operation
azure-powershell copied to clipboard

Manged Run command on Windows VM (SetAzVmRUnCommand) is deafulting to powershell 5.1

Open Satyadm123 opened this issue 2 years ago • 5 comments

Description

I am trying to execute Powershell scripts using run commands on Windows VM. I have powershell 7 installed on the server. But Powershell 7 is not selected and it defaults to Powershell 5 while executing Run commands. Is it possible to select Powershell 7 for execution via run co mmands (Invoke Az VM run command/Set AzVM Run command)? I have tried creating a profile and mentioning pwsh.exe but I get error when I execute a Powershell via SetAzVMRun Command

Issue script & Debug output

Powershell script executed via https://learn.microsoft.com/en-us/azure/virtual-machines/windows/run-command-managed

Environment data

Azure Windows VM server 2016

Module versions

Powershell 7

Error output

.
pwsh.exe : The term 'pwsh.exe' is not recognized as the name of a cmdlet, 

function, script file, or operable program. Check the spelling of the name, or 
if a path was included, verify that the path is correct and try again.
At C:\Windows\System32\WindowsPowerShell\v1.0\profile.ps1:3 char:1

Satyadm123 avatar Aug 06 '23 13:08 Satyadm123

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @Drewm3, @TravisCragg-MSFT, @nikhilpatel909, @sandeepraichura, @hilaryw29, @GabstaMSFT.

Issue Details

Description

I am trying to execute Powershell scripts using run commands on Windows VM. I have powershell 7 installed on the server. But Powershell 7 is not selected and it defaults to Powershell 5 while executing Run commands. Is it possible to select Powershell 7 for execution via run co mmands (Invoke Az VM run command/Set AzVM Run command)? I have tried creating a profile and mentioning pwsh.exe but I get error when I execute a Powershell via SetAzVMRun Command

Issue script & Debug output

Powershell script executed via https://learn.microsoft.com/en-us/azure/virtual-machines/windows/run-command-managed

Environment data

Azure Windows VM server 2016

Module versions

Powershell 7

Error output

.
pwsh.exe : The term 'pwsh.exe' is not recognized as the name of a cmdlet, 

function, script file, or operable program. Check the spelling of the name, or 
if a path was included, verify that the path is correct and try again.
At C:\Windows\System32\WindowsPowerShell\v1.0\profile.ps1:3 char:1
Author: Satyadm123
Assignees: -
Labels:

Compute - VM, Service Attention, bug, customer-reported

Milestone: -

ghost avatar Aug 08 '23 03:08 ghost

@nikhilpatel909 can you have a look at this?

TravisCragg-MSFT avatar Aug 10 '23 19:08 TravisCragg-MSFT

This will be a new feature request to Powershell team.

nikhilpatel909 avatar Aug 15 '23 16:08 nikhilpatel909

My bad, This is actually a feature request to run command so it will stay with me, We will evaluate and prioritize.

nikhilpatel909 avatar Aug 15 '23 16:08 nikhilpatel909

@Satyadm123 this is still on our roadmap and we are in internal discussions on this topic.

GabstaMSFT avatar Jun 27 '24 15:06 GabstaMSFT

@Satyadm123 we are testing a change and expect to be releasing an update once testing is completed.

GabstaMSFT avatar Jul 25 '24 20:07 GabstaMSFT

Get @GabstaMSFT, any update on this? It selecting 5.1 is causing some issue for me as I need some features that are only available in PowerShell Core

AlexanderSehr avatar Jan 18 '25 22:01 AlexanderSehr

@AlexanderSehr we have started rolling out the change to Azure, once the rollout is complete I will update here. I anticipate it will be completed by the end of the month.

GabstaMSFT avatar Feb 06 '25 20:02 GabstaMSFT

@AlexanderSehr we have started rolling out the change to Azure, once the rollout is complete I will update here. I anticipate it will be completed by the end of the month.

@GabstaMSFT any update on this? (we are on West-Europe)

sohoclemz avatar Mar 11 '25 10:03 sohoclemz

The rollout has completed and this issue should be resolved.

GabstaMSFT avatar Apr 15 '25 14:04 GabstaMSFT

@GabstaMSFT is there any documentation on how to use PowerShell 7 with managed run commands?

klamir051 avatar Apr 25 '25 04:04 klamir051

Hi @klamir051 ,

  • Set-AzVMRunCommand cmdlet does not have the "scriptShell" parameter yet. We will raise a request with Powershell team to include that.
  • REST API specs should reflect "ScriptShell" in few months. A change has been made for that and public docs need to be published yet. How to use: Just add another property called scriptShell under properties, parallel to source "properties": { "source": { "script": "Write-Host HelloWorld" }, "scriptShell" : "Powershell7" }

viveklingaiah avatar May 02 '25 16:05 viveklingaiah

Hi, we're sending this friendly reminder because we haven't heard back from you in a while. We need more information about this issue to help address it. Please be sure to give us your input within the next 7 days. If we don't hear back from you within 14 days of this comment the issue will be automatically closed. Thank you!