Create VM in azure using powershell

Laxmanprabhu 5 Reputation points
2023-05-18T06:48:55.55+00:00

Unable to create the Azure Windows 10 VM using powershell script.

Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
8,134 questions
{count} vote

1 answer

Sort by: Most helpful
  1. vipullag-MSFT 26,411 Reputation points
    2023-05-18T08:32:59.02+00:00

    Hello Laxmanprabhu

    Thanks for sharing more details:

    The error message you are receiving is because the image name you are using is incorrect. The image name should be "Win10" instead of "Windows 10 Pro, version 22H2 - x64 Gen2".

    Please try the following PowerShell script to create a Windows 10 VM:

    New-AzVm `
        -ResourceGroupName "Test_group" `
        -Name "myVM2" `
        -Location "EastUS" `
        -VirtualNetworkName "WhizTech" `
        -SubnetName "default" `
        -SecurityGroupName "whiz-Ind" `
        -PublicIpAddressName "whizvm-2" `
        -ImageName "Win10" `
        -Size "Standard_B2s" `
        -Credential (Get-Credential) `
        -OpenPorts 3389
    

    This script creates a new Windows 10 VM in the "EastUS" region, using the "WhizTech" virtual network and "default" subnet. It also creates a new public IP address and opens port 3389 for remote desktop access.

    Please note that you will be prompted to enter your Azure credentials when you run this script.

    Hope this helps.

    If the suggested response helped you resolve your issue, please 'Accept as answer', so that it can help others in the community looking for help on similar topics.


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.