0
votes

I am trying to run a PowerShell vmss custom extension script on scale set.

I get this error when it tries to run the Update-AzureRmVmss command Update-AzureRmVmss : Required parameter 'adminPassword' is missing (null). ErrorCode: InvalidParameter ErrorMessage: Required parameter 'adminPassword' is missing (null). StatusCode: 400 ReasonPhrase: Bad Request

$customConfig = @{
 "fileUris" = @("https://$storageAccountName.blob.core.windows.net/scripts/script.ps1");
"commandToExecute" = "PowerShell -ExecutionPolicy Unrestricted .\script.ps1";
};
# Add the extension to the config
$vmss = Get-AzureRmVmss -ResourceGroupName $resourceGroup -VMScaleSetName $vmssname
Add-AzureRmVmssExtension -VirtualMachineScaleSet $vmss -Publisher Microsoft.Compute -Type CustomScriptExtension -TypeHandlerVersion 2.0 -Name "runscript" -Setting $customConfig
# Send the new config to Azure
Update-AzureRmVmss -ResourceGroupName $resourceGroup -Name "runscript" -VirtualMachineScaleSet $vmss
3

3 Answers

4
votes

I figured out the issue. The -Name needs to be scaleset name. The code I got from online had the name as the name of the script which was wrong.

Update-AzureRmVmss -ResourceGroupName $resourceGroup -Name "scalsetname" -VirtualMachineScaleSet $vmss
0
votes

It might be easier to use the PowerShell cmdlet or CLI commands to add an extension directly..

PowerShell: Add-AzureRmVmssExtension CLI: az vmss extension set

The Azure Cloud Shell has a built in authenticated version of CLI.

0
votes

The correct parameter for Update-AzureRmVmss is -VMScaleSetName which also has an alias called Name. I was also getting the same error using -Name parameter, but when I tried using -VMScaleSetName in place of -Name, I do not see the error.

Here is the official documentation for reference: https://docs.microsoft.com/en-us/powershell/module/azurerm.compute/update-azurermvmss?view=azurermps-6.9.0

Update-AzureRmVmss -ResourceGroupName $resourceGroup -VMScaleSetName "scalesetname" -VirtualMachineScaleSet $vmss