Azure / Azure/azure-cli

Azure vm run-command Invoke Powershell: Local System

Open
#19,449 1 comment 0 reactions 1 assignee Claimed by @zhoxing-ms View on GitHub
act-observability-squad Compute customer-reported feature-request
Dominant language
Python
Stars
4.6k
Forks
3.5k
Avg merge
3d 2h
Merged PRs (30d)
60

Description

> ### `az feedback` auto-generates most of the information requested below, as of CLI version 2.0.62

**Describe the bug**
When run some Powershell commands (Add-AppxPackage ) using _az vm run-command invoke_ return a permissions error
(Run the same script directly on the VM works fine)

![image](https://user-images.githubusercontent.com/15262462/132007743-265ed389-7f11-43d6-b8d5-058c488b8107.png)

**To Reproduce**
Call PowerShell script from Azure using Azure Invoke

Azure Invoke call:
```
az vm run-command invoke \
--command-id RunPowerShellScript \
--resource-group ${VM_ResourceGroup} \
--name ${VM_Name_Long} \
--scripts @./scripts/06-InstallSoft.ps1
exit 0
```

PowerShell Code:
```
$Filepath = "C:\Users\Public\Downloads"
$URL_Winget = "https://github.com/microsoft/winget-cli/releases/download/v1.0.11692/Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle"
$FileName_Winget = "Microsoft.DesktopAppInstaller.msixbundle"

function Install_Package ([string]$URL,[string]$Path,[Int]$Timer) {
Invoke-WebRequest -uri $URL -OutFile $Path
Add-AppxPackage $Path
Start-Sleep -Seconds $Timer
}

Install_Package $URL_Winget "$Filepath\$FileName_Winget" 10
```

**Expected behavior**
Run powershell from Azure CLI, must allow run any command. Specially when these scripts are useful to install software (msixbundle)

**Environment**
```
arp@Oryx-Pro:~/Desktop/Azure CLI$ az --version
azure-cli 2.27.2

core 2.27.2
telemetry 1.0.6

Python location '/opt/az/bin/python3'
Extensions directory '/home/arp/.azure/cliextensions'

Python (Linux) 3.6.10 (default, Aug 23 2021, 03:36:00)
[GCC 9.3.0]
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.