Azure Arc command-line tools cheat sheet

Examples of how to do basic things using the az cli and Azure PowerShell modules for Azure Arc for Servers

Edwin Young

2 minute read

Arc for Servers has a new Azure CLI extension and PowerShell module. Both are still experimental, so expect a few rough edges and please report any issues you see. Because they are prerelease, they are not included (yet) in the main releases (ie, you don’t get this just by installing az cli or the Az module). However they are already functional and useful. Here’s how to do some simple operations with each of them.



az extension add connectedmachine

Azure PowerShell:

Install-Module -Name Az.ConnectedMachine

List machines


az connectedmachine list

# only display a few properties in a convenient form
az connectedmachine list --query "[].{Name:name,ResourceGroup:resourceGroup,Location:location,Status:status}" -o table

Azure PowerShell:


List extensions installed on a machine


az connectedmachine extension list --resource-group edyoung --machine-name edwin-virtual-machine

Azure PowerShell:

Get-AzConnectedMachineExtension -ResourceGroupName edyoung -MachineName edwin-virtual-machine

Install Custom Script Extension on a windows machine and run ‘dir’

Note that installing extensions currently takes several minutes. Please be patient.

AZ CLI run in bash

# Note --location needs to be the location of the machine
az connectedmachine extension create --machine-name silverbox-ne --resource-group edyoung --name myext --type "CustomScriptExtension" --publisher "Microsoft.Compute" --settings '{"commandToExecute":"dir"}' --location "North Europe"

AZ CLI run inside PowerShell (the escaping is different for settings param)

az connectedmachine extension create --machine-name silverbox-ne --resource-group edyoung --name myext --type "CustomScriptExtension" --publisher "Microsoft.Compute" --settings '{\"commandToExecute\":\"dir\"}' --location "North Europe"

Azure PowerShell

 New-AzConnectedMachineExtension -MachineName silverbox-ne -ResourceGroupName edyoung -Location "North Europe" -Name myext -Setting '{"commandToExecute":"dir"}' -ExtensionType CustomScriptExtension -Publisher Microsoft.Compute

Delete an extension


az connectedmachine extension delete --name myext -g edyoung --machine-name silverbox-ne

Azure PowerShell

Remove-AzConnectedMachineExtension -MachineName silverbox-ne -ResourceGroupName edyoung -Name myext