Azure / azure-powershell

Microsoft Azure PowerShell
Other
4.12k stars 3.76k forks source link

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

Open Satyadm123 opened 11 months ago

Satyadm123 commented 11 months ago

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
ghost commented 11 months ago

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 Powershell script executed via https://learn.microsoft.com/en-us/azure/virtual-machines/windows/run-command-managed ``` ### Environment data ```PowerShell Azure Windows VM server 2016 ``` ### Module versions ```PowerShell Powershell 7 ``` ### Error output ```PowerShell . 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: -
TravisCragg-MSFT commented 11 months ago

@nikhilpatel909 can you have a look at this?

nikhilpatel909 commented 10 months ago

This will be a new feature request to Powershell team.

nikhilpatel909 commented 10 months ago

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

GabstaMSFT commented 1 week ago

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