diff --git a/src/ResourceManager/Compute/Commands.Compute/help/New-AzureRmVM.md b/src/ResourceManager/Compute/Commands.Compute/help/New-AzureRmVM.md index f683ff6da3f5..898ce4018efe 100644 --- a/src/ResourceManager/Compute/Commands.Compute/help/New-AzureRmVM.md +++ b/src/ResourceManager/Compute/Commands.Compute/help/New-AzureRmVM.md @@ -1,4 +1,4 @@ ---- +--- external help file: Microsoft.Azure.Commands.Compute.dll-Help.xml ms.assetid: 05E6155D-4F0E-406B-9312-77AD97EF66EE online version: https://docs.microsoft.com/en-us/powershell/module/azurerm.compute/new-azurermvm @@ -12,69 +12,35 @@ Creates a virtual machine. ## SYNTAX +### DefaultParameterSet (Default) ``` New-AzureRmVM [-ResourceGroupName] [-Location] [-VM] [[-Zone] ] [-DisableBginfoExtension] [-Tags ] [-LicenseType ] [-DefaultProfile ] [-WhatIf] [-Confirm] [] ``` +### StrategyParameterSet +``` +New-AzureRmVM [[-ResourceGroupName] ] [[-Location] ] -Name -Credential + [-VirtualNetworkName ] [-AddressPrefix ] [-SubnetName ] + [-SubnetAddressPrefix ] [-PublicIpAddressName ] [-DomainNameLabel ] + [-AllocationMethod ] [-SecurityGroupName ] [-OpenPorts ] [-ImageName ] + [-DefaultProfile ] [-WhatIf] [-Confirm] [] +``` + ## DESCRIPTION The **New-AzureRmVM** cmdlet creates a virtual machine in Azure. This cmdlet takes a virtual machine object as input. Use the New-AzureRmVMConfig cmdlet to create a virtual machine object. Other cmdlets can be used to configure the virtual machine, such as Set-AzureRmVMOperatingSystem, Set-AzureRmVMSourceImage, Add-AzureRmVMNetworkInterface, and Set-AzureRmVMOSDisk. +The `StrategyParameterSet` provides a convenient method to create a VM by making common VM creation arguments optional. + ## EXAMPLES ### Example 1: Create a virtual machine ``` -PS C:\> # Variables -## Global -$ResourceGroupName = "ResourceGroup11" -$Location = "WestEurope" - -## Storage -$StorageName = "generalstorage6cc" -$StorageType = "Standard_GRS" - -## Network -$InterfaceName = "ServerInterface06" -$Subnet1Name = "Subnet1" -$VNetName = "VNet09" -$VNetAddressPrefix = "10.0.0.0/16" -$VNetSubnetAddressPrefix = "10.0.0.0/24" - -## Compute -$VMName = "VirtualMachine12" -$ComputerName = "Server22" -$VMSize = "Standard_A2" -$OSDiskName = $VMName + "OSDisk" - -# Resource Group -New-AzureRmResourceGroup -Name $ResourceGroupName -Location $Location - -# Storage -$StorageAccount = New-AzureRmStorageAccount -ResourceGroupName $ResourceGroupName -Name $StorageName -Type $StorageType -Location $Location - -# Network -$PIp = New-AzureRmPublicIpAddress -Name $InterfaceName -ResourceGroupName $ResourceGroupName -Location $Location -AllocationMethod Dynamic -$SubnetConfig = New-AzureRmVirtualNetworkSubnetConfig -Name $Subnet1Name -AddressPrefix $VNetSubnetAddressPrefix -$VNet = New-AzureRmVirtualNetwork -Name $VNetName -ResourceGroupName $ResourceGroupName -Location $Location -AddressPrefix $VNetAddressPrefix -Subnet $SubnetConfig -$Interface = New-AzureRmNetworkInterface -Name $InterfaceName -ResourceGroupName $ResourceGroupName -Location $Location -SubnetId $VNet.Subnets[0].Id -PublicIpAddressId $PIp.Id - -# Compute - -## Setup local VM object -$Credential = Get-Credential -$VirtualMachine = New-AzureRmVMConfig -VMName $VMName -VMSize $VMSize -$VirtualMachine = Set-AzureRmVMOperatingSystem -VM $VirtualMachine -Windows -ComputerName $ComputerName -Credential $Credential -ProvisionVMAgent -EnableAutoUpdate -$VirtualMachine = Set-AzureRmVMSourceImage -VM $VirtualMachine -PublisherName MicrosoftWindowsServer -Offer WindowsServer -Skus 2012-R2-Datacenter -Version "latest" -$VirtualMachine = Add-AzureRmVMNetworkInterface -VM $VirtualMachine -Id $Interface.Id -$OSDiskUri = $StorageAccount.PrimaryEndpoints.Blob.ToString() + "vhds/" + $OSDiskName + ".vhd" -$VirtualMachine = Set-AzureRmVMOSDisk -VM $VirtualMachine -Name $OSDiskName -VhdUri $OSDiskUri -CreateOption FromImage - -## Create the VM in Azure -New-AzureRmVM -ResourceGroupName $ResourceGroupName -Location $Location -VM $VirtualMachine +PS C:\> New-AzureRmVM -Name MyVm ``` This example script shows how to create a virtual machine. @@ -138,6 +104,52 @@ You can confirm your login status by using the **Get-AzureSubscription** cmdlet. ## PARAMETERS +### -AddressPrefix +The address prefix for the virtual network which will be created for the VM. + +```yaml +Type: String +Parameter Sets: StrategyParameterSet +Aliases: + +Required: False +Position: Named +Default value: 192.168.0.0/16 +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -AllocationMethod +The IP allocation method for the public IP which will be created for the VM. + +```yaml +Type: String +Parameter Sets: StrategyParameterSet +Aliases: +Accepted values: Static, Dynamic + +Required: False +Position: Named +Default value: Static +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Credential +The administrator credentials for the VM. + +```yaml +Type: PSCredential +Parameter Sets: StrategyParameterSet +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -DefaultProfile The credentials, account, tenant, and subscription used for communication with azure. @@ -158,7 +170,22 @@ Indicates that this cmdlet does not install the **BG Info** extension on the vir ```yaml Type: SwitchParameter -Parameter Sets: (All) +Parameter Sets: DefaultParameterSet +Aliases: + +Required: False +Position: 3 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -DomainNameLabel +The subdomain label for the fully-qualified domain name (FQDN) of the VM. This will take the form `{domainNameLabel}.{location}.cloudapp.azure.com`. + +```yaml +Type: String +Parameter Sets: StrategyParameterSet Aliases: Required: False @@ -168,6 +195,21 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -ImageName +The friendly image name upon which the VM will be built. These include: Win2016Datacenter, Win2012R2Datacenter, Win2012Datacenter, Win2008R2SP1, UbuntuLTS, CentOS, CoreOS, Debian, openSUSE-Leap, RHEL, SLES. + +```yaml +Type: String +Parameter Sets: StrategyParameterSet +Aliases: + +Required: False +Position: Named +Default value: Win2016Datacenter +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -LicenseType Specifies a license type, which indicates that the image or disk for the virtual machine was licensed on-premises. This value is used only for images that contain the Windows Server operating system. @@ -181,7 +223,7 @@ If you specify this parameter for an update, the value must match the initial va ```yaml Type: String -Parameter Sets: (All) +Parameter Sets: DefaultParameterSet Aliases: Required: False @@ -196,7 +238,7 @@ Specifies a location for the virtual machine. ```yaml Type: String -Parameter Sets: (All) +Parameter Sets: DefaultParameterSet Aliases: Required: True @@ -206,12 +248,69 @@ Accept pipeline input: True (ByPropertyName) Accept wildcard characters: False ``` +```yaml +Type: String +Parameter Sets: StrategyParameterSet +Aliases: + +Required: False +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Name +The name of the VM resource. + +```yaml +Type: String +Parameter Sets: StrategyParameterSet +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -OpenPorts +A list of ports to open on the network security group (NSG) for the created VM. The default value depends on the type of image chosen (i.e., Windows: 3389, 5985 and Linux: 22). + +```yaml +Type: Int32[] +Parameter Sets: StrategyParameterSet +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -PublicIpAddressName +The name of a new (or existing) public IP address for the created VM to use. If not specified, a name will be generated. + +```yaml +Type: String +Parameter Sets: StrategyParameterSet +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -ResourceGroupName Specifies the name of a resource group. ```yaml Type: String -Parameter Sets: (All) +Parameter Sets: DefaultParameterSet Aliases: Required: True @@ -221,6 +320,63 @@ Accept pipeline input: True (ByPropertyName) Accept wildcard characters: False ``` +```yaml +Type: String +Parameter Sets: StrategyParameterSet +Aliases: + +Required: False +Position: 0 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -SecurityGroupName +The name of a new (or existing) network security group (NSG) for the created VM to use. If not specified, a name will be generated. + +```yaml +Type: String +Parameter Sets: StrategyParameterSet +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -SubnetAddressPrefix +The address prefix for the subnet which will be created for the VM. + +```yaml +Type: String +Parameter Sets: StrategyParameterSet +Aliases: + +Required: False +Position: Named +Default value: 192.168.1.0/24 +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -SubnetName +The name of a new (or existing) subnet for the created VM to use. If not specified, a name will be generated. + +```yaml +Type: String +Parameter Sets: StrategyParameterSet +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -Tags Specifies that resources and resource groups can be tagged with a set of name-value pairs. Adding tags to resources enables you to group resources together across resource groups and to create your own views. @@ -228,7 +384,7 @@ Each resource or resource group can have a maximum of 15 tags. ```yaml Type: Hashtable -Parameter Sets: (All) +Parameter Sets: DefaultParameterSet Aliases: Required: False @@ -238,6 +394,21 @@ Accept pipeline input: True (ByPropertyName) Accept wildcard characters: False ``` +### -VirtualNetworkName +The name of a new (or existing) virtual network for the created VM to use. If not specified, a name will be generated. + +```yaml +Type: String +Parameter Sets: StrategyParameterSet +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -VM Specifies a local virtual machine to create. To obtain a virtual machine object, use the New-AzureRmVMConfig cmdlet. @@ -245,7 +416,7 @@ Other cmdlets can be used to configure the virtual machine, such as Set-AzureRmV ```yaml Type: PSVirtualMachine -Parameter Sets: (All) +Parameter Sets: DefaultParameterSet Aliases: VMProfile Required: True @@ -260,7 +431,7 @@ Specifies the zone list of the virtual machine. ```yaml Type: String[] -Parameter Sets: (All) +Parameter Sets: DefaultParameterSet Aliases: Required: False