@@ -134,6 +134,40 @@ This script can be used for automatic provisioning because it uses the local vir
134
134
This script assumes that you are already logged into your Azure account.
135
135
You can confirm your login status by using the ** Get-AzureSubscription** cmdlet.
136
136
137
+ ### Example 3: Create a VM from a marketplace image without a Public IP
138
+ ```
139
+ $VMLocalAdminUser = "LocalAdminUser"
140
+ $VMLocalAdminSecurePassword = ConvertTo-SecureString <password> -AsPlainText -Force
141
+ $LocationName = "westus"
142
+ $ResourceGroupName = "MyResourceGroup"
143
+ $ComputerName = "MyVM"
144
+ $VMName = "MyVM"
145
+ $VMSize = "Standard_DS3"
146
+
147
+ $NetworkName = "MyNet"
148
+ $NICName = "MyNIC"
149
+ $SubnetName = "MySubnet"
150
+ $SubnetAddressPrefix = "10.0.0.0/24"
151
+ $VnetAddressPrefix = "10.0.0.0/16"
152
+
153
+ $SingleSubnet = New-AzureRmVirtualNetworkSubnetConfig -Name $SubnetName -AddressPrefix $SubnetAddressPrefix
154
+ $Vnet = New-AzureRmVirtualNetwork -Name $NetworkName -ResourceGroupName $ResourceGroupName -Location $LocationName -AddressPrefix $VnetAddressPrefix -Subnet $SingleSubnet
155
+ $NIC = New-AzureRmNetworkInterface -Name $NICName -ResourceGroupName $ResourceGroupName -Location $LocationName -SubnetId $Vnet.Subnets[0].Id
156
+
157
+ $Credential = New-Object System.Management.Automation.PSCredential ($VMLocalAdminUser, $VMLocalAdminSecurePassword);
158
+
159
+ $VirtualMachine = New-AzureRmVMConfig -VMName $VMName -VMSize $VMSize
160
+ $VirtualMachine = Set-AzureRmVMOperatingSystem -VM $VirtualMachine -Windows -ComputerName $ComputerName -Credential $Credential -ProvisionVMAgent -EnableAutoUpdate
161
+ $VirtualMachine = Add-AzureRmVMNetworkInterface -VM $VirtualMachine -Id $NIC.Id
162
+ $VirtualMachine = Set-AzureRmVMSourceImage -VM $VirtualMachine -PublisherName 'MicrosoftWindowsServer' -Offer 'WindowsServer' -Skus '2012-R2-Datacenter' -Version latest
163
+
164
+ New-AzureRmVM -ResourceGroupName $ResourceGroupName -Location $LocationName -VM $VirtualMachine -Verbose
165
+ ```
166
+
167
+ This example provisions a new network and deploys a Windows VM from the Marketplace without creating a public IP address or Network Security Group.
168
+
169
+ This script can be used for automatic provisioning because it uses the local virtual machine admin credentials inline instead of calling ** Get-Credential** which requires user interaction.
170
+
137
171
## PARAMETERS
138
172
139
173
### -AddressPrefix
0 commit comments