How to do it...

The steps for the recipe are as follows:

  1. Define key variables
      $Locname = 'uksouth'          # location name
      $RgName  = 'packt_rg'         # resource group name
      $SAName  = 'packt100sa'       # Storage account name
      $NSGName = 'packt_nsg'        # NSG name
      $FullNet = '10.10.0.0/16'     # Overall networkrange
      $CLNet   = '10.10.2.0/24'     # Our cloud subnet 
      $GWNet   = '192.168.200.0/26' # Gateway subnet
      $DNS     = '8.8.8.8'          # DNS Server to use 
      $IPName = 'Packt_IP1'         # Private IP Address name
      $VMName = "Packt100"          # the name of the vm
      $CompName = "Packt100"        # the name of the VM host
  1. Just in case, log in to Azure and ensure the resource group and storage account exist:
       Login-AzureRmAccount 
       $RG = Get-AzureRmResourceGroup -Name $RgName ` -ErrorAction SilentlyContinue ...

Get Windows Server 2016 Automation with PowerShell Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.