common/code-upgrade-samples/az/compute-create-windowsvm-quick.ps1 (21 lines of code) (raw):

# Original source code: https://github.com/Azure/azure-docs-powershell-samples/blob/a513b6fceae51aaea1daaa8edd4d6fc66590d172/virtual-machine/create-vm-detailed/create-windows-vm-quick.ps1 # Variables for common values $resourceGroup = "myResourceGroup" $location = "westeurope" $vmName = "myVM" # Create user object $cred = Get-Credential -Message "Enter a username and password for the virtual machine." # Create a resource group New-AzResourceGroup -Name $resourceGroup -Location $location # Create a virtual machine New-AzVM ` -ResourceGroupName $resourceGroup ` -Name $vmName ` -Location $location ` -Image "Win2016Datacenter" ` -VirtualNetworkName "myVnet" ` -SubnetName "mySubnet" ` -SecurityGroupName "myNetworkSecurityGroup" ` -PublicIpAddressName "myPublicIp" ` -Credential $cred ` -OpenPorts 3389