After Running this command on Azure Cli:
az vm extension set --publisher Microsoft.Compute --version 1.8 --name CustomScriptExtension --vm-name avmUat --resource-group argUat --settings '{"commandToExecute":"powershell.exe Install-WindowsFeature -Name Web-Server"}'
I get this error
Deployment failed. Correlation ID: 8d6972da-6d46-42e8-a053-f8e899348893. VM has reported a failure when processing extension 'CustomScriptExtension'. Error message: "Invalid handler configuration. Exiting. Error Message: Error converting value "{commandToExecute:powershell.exe Install-WindowsFeature -Name Web-Server}" to type 'Microsoft.WindowsAzure.GuestAgent.Plugins.CustomScriptHandler.PublicSettings'. Path 'runtimeSettings[0].handlerSettings.publicSettings', line 5, position 102.".
Edit: The result when I run it in powershell on Azure Cloud Shell:
-command
before the scriptblock of calling powershell.exe? – Falco Alexander