how to create a VM with public ip address with"new-azvm -vm $vm"

Yuxiang 21 Reputation points
2021-12-02T09:17:25.323+00:00

how to create a VM with public ip address with"new-azvm -vm $vm"

I know "New-AzVm -PublicIpAddressName" can create it,but it can't select operatingsystem image(-PublisherName $pubName -Offer $offerName -Skus $skuName...)

Is it possible to create a configurable VM with publicipaddress via "new-azvm-vm $vm"

Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
7,584 questions
0 comments No comments
{count} votes

Accepted answer
  1. Manu Philip 17,671 Reputation points MVP
    2021-12-02T09:40:21.8+00:00

    Here is how you can select the operating system using PS script
    $Publisher = Get-AzVMImagePublisher -Location 'East US' | Where-Object PublisherName -eq "MicrosoftWindowsServer"
    $Offer = $Publisher | Get-AzVMImageOffer | Where-Object Offer -eq "WindowsServer"
    $Sku = $Offer | Get-AzVMImageSku | Where-Object Skus -eq "2019-Datacenter"
    $VMImage = $Sku | Get-AzVMImage | Select-Object -Last 1
    # $VMImage now has following properties variables
    # - publisher
    # - offer
    # - sku
    # - image


0 additional answers

Sort by: Most helpful