Azure vm run-command Invoke Powershell: Local System
- 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)

**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
Assessment
This issue has not been assessed yet.