New-AzVM in powershell is not activating GUI in for Windows Server Datacenter Editions

Alberto Mijares (Tantius) 81 Reputation points
2023-08-24T03:47:34.0133333+00:00

When I Crete a VM from Azure Console for "2022-datacenter-azure-edition-hotpatch" and connect to it I access the GUI. However if I create the VM via Powershell I go directly to sConfig.

How can I create the VM so that I have the GUI at startup?

Thanks

$VirtualMachine = New-AzVMConfig -VMName $ComputerName -VMSize 'Standard_B1ms'
$VirtualMachine = Set-AzVMOperatingSystem -VM $VirtualMachine -Windows -ComputerName $ComputerName -Credential $Credential -ProvisionVMAgent -EnableAutoUpdate
$VirtualMachine = Add-AzVMNetworkInterface -VM $VirtualMachine -Id $NIC.Id -DeleteOption "Delete"
$VirtualMachine = Set-AzVMSourceImage -VM $VirtualMachine -PublisherName 'MicrosoftWindowsServer' -Offer 'WindowsServer' -Skus '2022-datacenter-azure-edition-hotpatch' -Version latest
$VirtualMachine = Set-AzVMOSDisk -VM $VirtualMachine -Name "$ComputerName-OsDisk" -StorageAccountType "Standard_LRS" -DiskSizeInGB 128 -DeleteOption  "Delete"  -Caching ReadWrite -Windows -CreateOption "FromImage" 

$vm_data=New-AzVM -ResourceGroupName $ResourceGroupName -Location $LocationName -VM $VirtualMachine

Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
7,254 questions
Windows Server Setup
Windows Server Setup
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.Setup: The procedures involved in preparing a software program or application to operate within a computer or mobile device.
241 questions
PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,139 questions
{count} votes

Accepted answer
  1. Olga Os - MSFT 5,836 Reputation points Microsoft Employee
    2023-08-30T23:11:09.1866667+00:00

    Hello Alberto Mijares (Tantius),

    Welcome to the MS Q&A forum.

    The details you provided are quite intriguing and captured my attention.

    I tried to reproduce the issue on my side by deploying the "2022-datacenter-azure-edition-hotpatch" from the Azure Marketplace in the Azure Portal and from PowerShell by using the 'New-AzVM' command and on both got access to GUI when I connected for the first time.

    Could you please confirm what you are seeing the same image parameters on both VMs in the Azure Portal?

    You could find these parameters under the VM overview or by navigating to the "Export Template".

    User's image

    User's image

    Did you deploy both VMs in the same region?

    Sincerely,

    Olga Os.

    0 comments No comments

0 additional answers

Sort by: Most helpful