Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Satyadm123 opened this issue Aug 6, 2023 · 13 comments
Assignees
Labels
Compute - VM customer-reported feature-request This issue requires a new behavior in the product in order be resolved. needs-author-feedback More information is needed from author to address the issue. no-recent-activity There has been no recent activity on this issue. Service Attention This issue is responsible by Azure service team.

Comments

@Satyadm123
Copy link

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 Satyadm123 added bug This issue requires a change to an existing behavior in the product in order to be resolved. needs-triage This is a new issue that needs to be triaged to the appropriate team. labels Aug 6, 2023
@ghost ghost added customer-reported and removed needs-triage This is a new issue that needs to be triaged to the appropriate team. labels Aug 6, 2023
@isra-fel isra-fel added Compute - VM Service Attention This issue is responsible by Azure service team. labels Aug 8, 2023
@ghost
Copy link

ghost commented Aug 8, 2023

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: -

@TravisCragg-MSFT
Copy link
Member

@nikhilpatel909 can you have a look at this?

@nikhilpatel909
Copy link

This will be a new feature request to Powershell team.

@nikhilpatel909 nikhilpatel909 added feature-request This issue requires a new behavior in the product in order be resolved. and removed bug This issue requires a change to an existing behavior in the product in order to be resolved. labels Aug 15, 2023
@nikhilpatel909
Copy link

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

@GabstaMSFT
Copy link
Member

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

@GabstaMSFT
Copy link
Member

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

@AlexanderSehr
Copy link

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

@GabstaMSFT
Copy link
Member

@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.

@sohoclemz
Copy link

sohoclemz commented Mar 11, 2025

@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)

@GabstaMSFT
Copy link
Member

The rollout has completed and this issue should be resolved.

@GabstaMSFT GabstaMSFT added the needs-author-feedback More information is needed from author to address the issue. label Apr 15, 2025
@microsoft-github-policy-service microsoft-github-policy-service bot added the no-recent-activity There has been no recent activity on this issue. label Apr 22, 2025
@klamir051
Copy link

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

@microsoft-github-policy-service microsoft-github-policy-service bot removed the no-recent-activity There has been no recent activity on this issue. label Apr 25, 2025
@microsoft-github-policy-service microsoft-github-policy-service bot added the no-recent-activity There has been no recent activity on this issue. label May 2, 2025
@viveklingaiah
Copy link
Contributor

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"
    }

@microsoft-github-policy-service microsoft-github-policy-service bot removed the no-recent-activity There has been no recent activity on this issue. label May 2, 2025
@microsoft-github-policy-service microsoft-github-policy-service bot added the no-recent-activity There has been no recent activity on this issue. label May 9, 2025
Copy link
Contributor

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Compute - VM customer-reported feature-request This issue requires a new behavior in the product in order be resolved. needs-author-feedback More information is needed from author to address the issue. no-recent-activity There has been no recent activity on this issue. Service Attention This issue is responsible by Azure service team.
Projects
None yet
Development

No branches or pull requests

10 participants