Today, all scripts run through Managed RunCommand will by default use Powershell 5. What if you have a script that requires Powershell7? This is supported via a new feature, but you will need to specify the different script shell.Here's what you need to do.Ensure your VM has Powershell7Powershell7 is not installed by default. To ensure it's available on your machine, you have the following options. Create a VM image with Powershell7 pre-installed and use that to create your VMs. For more information on creating images, see here. For information on sharing images, see here. Use RunCommand to install Powershell7 on your VM.Here's an example on how to do this:az vm run-command create --name "blah" --vm-name $vmname--resource-group $rg --script "Invoke-WebRequest -Uri https://github.com/PowerShell/PowerShell/releases/download/v7.4.6/PowerShell-7.4.6-win-x64.msi -OutFile PowerShell-7.msi; Start-Process msiexec.exe -ArgumentList '/i PowerShell-7.msi /quiet /norestart' -Wait;Remove-Item -Path PowerShell-7.msi" --location $locationBy the time you read this, you'll likely need to update the download of Powershell7, which can be found here.To verify that everything installed, check the instance view. Note that you may need to open an outbound networking rule for this to work.az vm run-command show --name "blah" --vm-name $vmname --resource-group $rg --expand instanceView3. Download the package yourself and create a VmApplication from it. More detail on VM Applications can be found here.This option is more complicated, but is useful in situations where your VM is locked down and you don't wish to open the outbound connection. Since VM Applications are downloaded via the host as a proxy, there's no need to open any ports.Run your script using Powershell7As of this writing, this feature isn't yet supported in the Portal (which only supports Action RunCommand and not Managed RunCommand), or via CLI and Powershell, where the necessary parameter isn't supported. You're therefore going to need to use an ARM template. Here is an example.{ "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", "contentVersion": "1.0.0.0", "resources": [ { "type": "Microsoft.Compute/virtualMachines/runCommands", "apiVersion": "2024-07-01", "name": "[concat(parameters('vmName'), '/RunPowershellSeven')]", "location": "[parameters('region')]", "dependsOn": [], "properties": { "asyncExecution": false, "source": { "script": "Write-Output $PSVersionTable", "scriptShell": "Powershell7" }, "parameters": [] } } ], "parameters": { "vmName": { "type": "string", }, "region": { "type": "string" } }}Note the ScriptShell property that indicates the command should be run on Powershell7. Also note that the apiVersion must be at least 2024-07-01 for this to work.To run this command on a VM, you then may run:New-AzResourceGroupDeployment -ResourceGroupName $rg -TemplateFile $templateFilePath -vmName $vmname -region $regionAnd again to validate that the command ran:az vm run-command show --name "RunPowershellSeven" --vm-name $vmname --resource-group $rg --expand instanceViewOf course your script doesn't (and shouldn't typically be) in line. All of the standard Managed RunCommand properties that download a script are valid.