Can you explain the error in the command executed in the screenshot and guide how to resolve it

cs-user-0db1952cb89b 1 Reputation point
2021-05-15T04:36:16.59+00:00

![![96720-image.png]1]1

Not Monitored
Not Monitored
Tag not monitored by Microsoft.
44,037 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Ramya Harinarthini_MSFT 5,366 Reputation points Microsoft Employee Moderator
    2021-05-15T07:01:09.697+00:00

    @cs-user-0db1952cb89b Welcome to Microsoft Q&A, Thank you for posting your here!!

    Make sure to set the VM configuration object in $VirtualMachine first then set the operating system

    Create the VM configuration object

    $VmName = "VirtualMachinelatest"
    $VmSize = "Standard_A1"
    $VirtualMachine = New-AzVMConfig -VMName $VmName -VMSize $VmSize

    $VirtualMachine = Set-AzVMOperatingSystem -VM $VirtualMachine -Windows -ComputerName "MainComputer" -Credential $Credential -ProvisionVMAgent

    $VirtualMachine = Set-AzVMSourceImage -VM $VirtualMachine -PublisherName "MicrosoftWindowsServer" -Offer "WindowsServer" -Skus "2016-Datacenter" -Version "latest"

    For complete script please check the document here

    Hope this helps!
    Kindly let us know if the above helps or you need further assistance on this issue.

    -------------------------------------------------------------------------------------------------------------------

    Please do not forget to "Accept the answer” and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.