I’m trying to update a windows vm to have a system assigned managed identity.
I tried using the following commands.
$Vm = Get-AzVM -Name $vm_name -ResourceGroupName $rg -Status
Update-AzVM -ResourceGroupName $rg -VM $vm -IdentityType SystemAssigned
I’m getting the error message
Cannot convert the "Microsoft.Azure.Commands.Compute.Models.PSVirtualMachineInstanceView" value of type "Microsoft.Azure.Commands.Compute.Models.PSVirtualMachineInstanceView" to type "Microsoft.Azure.Commands.Compute.Models.PSVirtualMachine".
2
Answers
It turns out that the -Status flag on Get-AzVM returns a different object than without the -Status flag.
Try removing it and you will get an object that is compatible with Update-VM
i think the script is lil wrong with the variables, let me give you an updates script, hopefully it will works.