Skip to content

Commit b049751

Browse files
committed
Doc updates to New-AzureRmVM.
1 parent b5d723f commit b049751

File tree

1 file changed

+226
-55
lines changed

1 file changed

+226
-55
lines changed

src/ResourceManager/Compute/Commands.Compute/help/New-AzureRmVM.md

Lines changed: 226 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
---
1+
---
22
external help file: Microsoft.Azure.Commands.Compute.dll-Help.xml
33
ms.assetid: 05E6155D-4F0E-406B-9312-77AD97EF66EE
44
online version: https://docs.microsoft.com/en-us/powershell/module/azurerm.compute/new-azurermvm
@@ -12,69 +12,35 @@ Creates a virtual machine.
1212

1313
## SYNTAX
1414

15+
### DefaultParameterSet (Default)
1516
```
1617
New-AzureRmVM [-ResourceGroupName] <String> [-Location] <String> [-VM] <PSVirtualMachine> [[-Zone] <String[]>]
1718
[-DisableBginfoExtension] [-Tags <Hashtable>] [-LicenseType <String>]
1819
[-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
1920
```
2021

22+
### StrategyParameterSet
23+
```
24+
New-AzureRmVM [[-ResourceGroupName] <String>] [[-Location] <String>] -Name <String> -Credential <PSCredential>
25+
[-VirtualNetworkName <String>] [-AddressPrefix <String>] [-SubnetName <String>]
26+
[-SubnetAddressPrefix <String>] [-PublicIpAddressName <String>] [-DomainNameLabel <String>]
27+
[-AllocationMethod <String>] [-SecurityGroupName <String>] [-OpenPorts <Int32[]>] [-ImageName <String>]
28+
[-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
29+
```
30+
2131
## DESCRIPTION
2232
The **New-AzureRmVM** cmdlet creates a virtual machine in Azure.
2333
This cmdlet takes a virtual machine object as input.
2434
Use the New-AzureRmVMConfig cmdlet to create a virtual machine object.
2535
Other cmdlets can be used to configure the virtual machine, such as Set-AzureRmVMOperatingSystem, Set-AzureRmVMSourceImage, Add-AzureRmVMNetworkInterface, and Set-AzureRmVMOSDisk.
2636

37+
The `StrategyParameterSet` provides a convenient method to create a VM by making common VM creation arguments optional.
38+
2739
## EXAMPLES
2840

2941
### Example 1: Create a virtual machine
3042
```
31-
PS C:\> # Variables
32-
## Global
33-
$ResourceGroupName = "ResourceGroup11"
34-
$Location = "WestEurope"
35-
36-
## Storage
37-
$StorageName = "generalstorage6cc"
38-
$StorageType = "Standard_GRS"
39-
40-
## Network
41-
$InterfaceName = "ServerInterface06"
42-
$Subnet1Name = "Subnet1"
43-
$VNetName = "VNet09"
44-
$VNetAddressPrefix = "10.0.0.0/16"
45-
$VNetSubnetAddressPrefix = "10.0.0.0/24"
46-
47-
## Compute
48-
$VMName = "VirtualMachine12"
49-
$ComputerName = "Server22"
50-
$VMSize = "Standard_A2"
51-
$OSDiskName = $VMName + "OSDisk"
52-
53-
# Resource Group
54-
New-AzureRmResourceGroup -Name $ResourceGroupName -Location $Location
55-
56-
# Storage
57-
$StorageAccount = New-AzureRmStorageAccount -ResourceGroupName $ResourceGroupName -Name $StorageName -Type $StorageType -Location $Location
58-
59-
# Network
60-
$PIp = New-AzureRmPublicIpAddress -Name $InterfaceName -ResourceGroupName $ResourceGroupName -Location $Location -AllocationMethod Dynamic
61-
$SubnetConfig = New-AzureRmVirtualNetworkSubnetConfig -Name $Subnet1Name -AddressPrefix $VNetSubnetAddressPrefix
62-
$VNet = New-AzureRmVirtualNetwork -Name $VNetName -ResourceGroupName $ResourceGroupName -Location $Location -AddressPrefix $VNetAddressPrefix -Subnet $SubnetConfig
63-
$Interface = New-AzureRmNetworkInterface -Name $InterfaceName -ResourceGroupName $ResourceGroupName -Location $Location -SubnetId $VNet.Subnets[0].Id -PublicIpAddressId $PIp.Id
64-
65-
# Compute
66-
67-
## Setup local VM object
68-
$Credential = Get-Credential
69-
$VirtualMachine = New-AzureRmVMConfig -VMName $VMName -VMSize $VMSize
70-
$VirtualMachine = Set-AzureRmVMOperatingSystem -VM $VirtualMachine -Windows -ComputerName $ComputerName -Credential $Credential -ProvisionVMAgent -EnableAutoUpdate
71-
$VirtualMachine = Set-AzureRmVMSourceImage -VM $VirtualMachine -PublisherName MicrosoftWindowsServer -Offer WindowsServer -Skus 2012-R2-Datacenter -Version "latest"
72-
$VirtualMachine = Add-AzureRmVMNetworkInterface -VM $VirtualMachine -Id $Interface.Id
73-
$OSDiskUri = $StorageAccount.PrimaryEndpoints.Blob.ToString() + "vhds/" + $OSDiskName + ".vhd"
74-
$VirtualMachine = Set-AzureRmVMOSDisk -VM $VirtualMachine -Name $OSDiskName -VhdUri $OSDiskUri -CreateOption FromImage
75-
76-
## Create the VM in Azure
77-
New-AzureRmVM -ResourceGroupName $ResourceGroupName -Location $Location -VM $VirtualMachine
43+
PS C:\> New-AzureRmVM -Name MyVm
7844
```
7945

8046
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.
138104

139105
## PARAMETERS
140106

107+
### -AddressPrefix
108+
The address prefix for the virtual network which will be created for the VM.
109+
110+
```yaml
111+
Type: String
112+
Parameter Sets: StrategyParameterSet
113+
Aliases:
114+
115+
Required: False
116+
Position: Named
117+
Default value: 192.168.0.0/16
118+
Accept pipeline input: False
119+
Accept wildcard characters: False
120+
```
121+
122+
### -AllocationMethod
123+
The IP allocation method for the public IP which will be created for the VM.
124+
125+
```yaml
126+
Type: String
127+
Parameter Sets: StrategyParameterSet
128+
Aliases:
129+
Accepted values: Static, Dynamic
130+
131+
Required: False
132+
Position: Named
133+
Default value: Static
134+
Accept pipeline input: False
135+
Accept wildcard characters: False
136+
```
137+
138+
### -Credential
139+
The administrator credentials for the VM.
140+
141+
```yaml
142+
Type: PSCredential
143+
Parameter Sets: StrategyParameterSet
144+
Aliases:
145+
146+
Required: True
147+
Position: Named
148+
Default value: None
149+
Accept pipeline input: False
150+
Accept wildcard characters: False
151+
```
152+
141153
### -DefaultProfile
142154
The credentials, account, tenant, and subscription used for communication with azure.
143155
@@ -158,7 +170,22 @@ Indicates that this cmdlet does not install the **BG Info** extension on the vir
158170
159171
```yaml
160172
Type: SwitchParameter
161-
Parameter Sets: (All)
173+
Parameter Sets: DefaultParameterSet
174+
Aliases:
175+
176+
Required: False
177+
Position: 3
178+
Default value: None
179+
Accept pipeline input: False
180+
Accept wildcard characters: False
181+
```
182+
183+
### -DomainNameLabel
184+
The subdomain label for the fully-qualified domain name (FQDN) of the VM. This will take the form `{domainNameLabel}.{location}.cloudapp.azure.com`.
185+
186+
```yaml
187+
Type: String
188+
Parameter Sets: StrategyParameterSet
162189
Aliases:
163190
164191
Required: False
@@ -168,6 +195,21 @@ Accept pipeline input: False
168195
Accept wildcard characters: False
169196
```
170197

198+
### -ImageName
199+
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.
200+
201+
```yaml
202+
Type: String
203+
Parameter Sets: StrategyParameterSet
204+
Aliases:
205+
206+
Required: False
207+
Position: Named
208+
Default value: Win2016Datacenter
209+
Accept pipeline input: False
210+
Accept wildcard characters: False
211+
```
212+
171213
### -LicenseType
172214
Specifies a license type, which indicates that the image or disk for the virtual machine was licensed on-premises.
173215
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
181223

182224
```yaml
183225
Type: String
184-
Parameter Sets: (All)
226+
Parameter Sets: DefaultParameterSet
185227
Aliases:
186228
187229
Required: False
@@ -196,7 +238,7 @@ Specifies a location for the virtual machine.
196238

197239
```yaml
198240
Type: String
199-
Parameter Sets: (All)
241+
Parameter Sets: DefaultParameterSet
200242
Aliases:
201243
202244
Required: True
@@ -206,12 +248,69 @@ Accept pipeline input: True (ByPropertyName)
206248
Accept wildcard characters: False
207249
```
208250

251+
```yaml
252+
Type: String
253+
Parameter Sets: StrategyParameterSet
254+
Aliases:
255+
256+
Required: False
257+
Position: 1
258+
Default value: None
259+
Accept pipeline input: True (ByPropertyName)
260+
Accept wildcard characters: False
261+
```
262+
263+
### -Name
264+
The name of the VM resource.
265+
266+
```yaml
267+
Type: String
268+
Parameter Sets: StrategyParameterSet
269+
Aliases:
270+
271+
Required: True
272+
Position: Named
273+
Default value: None
274+
Accept pipeline input: False
275+
Accept wildcard characters: False
276+
```
277+
278+
### -OpenPorts
279+
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).
280+
281+
```yaml
282+
Type: Int32[]
283+
Parameter Sets: StrategyParameterSet
284+
Aliases:
285+
286+
Required: False
287+
Position: Named
288+
Default value: None
289+
Accept pipeline input: False
290+
Accept wildcard characters: False
291+
```
292+
293+
### -PublicIpAddressName
294+
The name of a new (or existing) public IP address for the created VM to use. If not specified, a name will be generated.
295+
296+
```yaml
297+
Type: String
298+
Parameter Sets: StrategyParameterSet
299+
Aliases:
300+
301+
Required: False
302+
Position: Named
303+
Default value: None
304+
Accept pipeline input: False
305+
Accept wildcard characters: False
306+
```
307+
209308
### -ResourceGroupName
210309
Specifies the name of a resource group.
211310

212311
```yaml
213312
Type: String
214-
Parameter Sets: (All)
313+
Parameter Sets: DefaultParameterSet
215314
Aliases:
216315
217316
Required: True
@@ -221,14 +320,71 @@ Accept pipeline input: True (ByPropertyName)
221320
Accept wildcard characters: False
222321
```
223322

323+
```yaml
324+
Type: String
325+
Parameter Sets: StrategyParameterSet
326+
Aliases:
327+
328+
Required: False
329+
Position: 0
330+
Default value: None
331+
Accept pipeline input: True (ByPropertyName)
332+
Accept wildcard characters: False
333+
```
334+
335+
### -SecurityGroupName
336+
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.
337+
338+
```yaml
339+
Type: String
340+
Parameter Sets: StrategyParameterSet
341+
Aliases:
342+
343+
Required: False
344+
Position: Named
345+
Default value: None
346+
Accept pipeline input: False
347+
Accept wildcard characters: False
348+
```
349+
350+
### -SubnetAddressPrefix
351+
The address prefix for the subnet which will be created for the VM.
352+
353+
```yaml
354+
Type: String
355+
Parameter Sets: StrategyParameterSet
356+
Aliases:
357+
358+
Required: False
359+
Position: Named
360+
Default value: 192.168.1.0/24
361+
Accept pipeline input: False
362+
Accept wildcard characters: False
363+
```
364+
365+
### -SubnetName
366+
The name of a new (or existing) subnet for the created VM to use. If not specified, a name will be generated.
367+
368+
```yaml
369+
Type: String
370+
Parameter Sets: StrategyParameterSet
371+
Aliases:
372+
373+
Required: False
374+
Position: Named
375+
Default value: None
376+
Accept pipeline input: False
377+
Accept wildcard characters: False
378+
```
379+
224380
### -Tags
225381
Specifies that resources and resource groups can be tagged with a set of name-value pairs.
226382
Adding tags to resources enables you to group resources together across resource groups and to create your own views.
227383
Each resource or resource group can have a maximum of 15 tags.
228384

229385
```yaml
230386
Type: Hashtable
231-
Parameter Sets: (All)
387+
Parameter Sets: DefaultParameterSet
232388
Aliases:
233389
234390
Required: False
@@ -238,14 +394,29 @@ Accept pipeline input: True (ByPropertyName)
238394
Accept wildcard characters: False
239395
```
240396

397+
### -VirtualNetworkName
398+
The name of a new (or existing) virtual network for the created VM to use. If not specified, a name will be generated.
399+
400+
```yaml
401+
Type: String
402+
Parameter Sets: StrategyParameterSet
403+
Aliases:
404+
405+
Required: False
406+
Position: Named
407+
Default value: None
408+
Accept pipeline input: False
409+
Accept wildcard characters: False
410+
```
411+
241412
### -VM
242413
Specifies a local virtual machine to create.
243414
To obtain a virtual machine object, use the New-AzureRmVMConfig cmdlet.
244415
Other cmdlets can be used to configure the virtual machine, such as Set-AzureRmVMOperatingSystem, Set-AzureRmVMSourceImage, and Add-AzureRmVMNetworkInterface.
245416

246417
```yaml
247418
Type: PSVirtualMachine
248-
Parameter Sets: (All)
419+
Parameter Sets: DefaultParameterSet
249420
Aliases: VMProfile
250421
251422
Required: True
@@ -260,7 +431,7 @@ Specifies the zone list of the virtual machine.
260431

261432
```yaml
262433
Type: String[]
263-
Parameter Sets: (All)
434+
Parameter Sets: DefaultParameterSet
264435
Aliases:
265436
266437
Required: False

0 commit comments

Comments
 (0)