Skip to content

Commit 70b3f85

Browse files
Merge pull request #179761 from mimckitt/patch-40
Update powershell-sample-install-apps.md
2 parents fca9d0c + e274eed commit 70b3f85

File tree

1 file changed

+48
-1
lines changed

1 file changed

+48
-1
lines changed

articles/virtual-machine-scale-sets/scripts/powershell-sample-install-apps.md

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,54 @@ This script creates a virtual machine scale set running Windows Server 2016 and
2020

2121
## Sample script
2222

23-
[!code-powershell[main](../../../powershell_scripts/virtual-machine-scale-sets/install-apps/install-apps.ps1 "Install apps into a scale set")]
23+
```powershell
24+
# Provide your own secure password for use with the VM instances
25+
$cred = Get-Credential
26+
27+
# Create a virtual machine scale set and supporting resources
28+
# A resource group, virtual network, load balancer, and NAT rules are automatically
29+
# created if they do not already exist
30+
New-AzVmss `
31+
-ResourceGroupName "myResourceGroup" `
32+
-VMScaleSetName "myScaleSet" `
33+
-Location "EastUS" `
34+
-VirtualNetworkName "myVnet" `
35+
-SubnetName "mySubnet" `
36+
-PublicIpAddressName "myPublicIPAddress" `
37+
-LoadBalancerName "myLoadBalancer" `
38+
-UpgradePolicyMode "Automatic" `
39+
-Credential $cred
40+
41+
# Create a configuration object to store the Custom Script Extension definition
42+
$customConfig = @{
43+
"fileUris" = (,"https://raw.githubusercontent.com/Azure-Samples/compute-automation-configurations/master/automate-iis.ps1");
44+
"commandToExecute" = "powershell -ExecutionPolicy Unrestricted -File automate-iis.ps1"
45+
}
46+
47+
# Get information about the scale set
48+
$vmss = Get-AzVmss `
49+
-ResourceGroupName "myResourceGroup" `
50+
-VMScaleSetName "myScaleSet"
51+
52+
# Add the Custom Script Extension to install IIS and configure basic website
53+
$vmss = Add-AzVmssExtension `
54+
-VirtualMachineScaleSet $vmss `
55+
-Name "customScript" `
56+
-Publisher "Microsoft.Compute" `
57+
-Type "CustomScriptExtension" `
58+
-TypeHandlerVersion 1.10 `
59+
-Setting $customConfig
60+
61+
# Update the scale set and apply the Custom Script Extension to the VM instances
62+
Update-AzVmss `
63+
-ResourceGroupName "myResourceGroup" `
64+
-Name "myScaleSet" `
65+
-VirtualMachineScaleSet $vmss
66+
67+
# Get the public IP address of your load balancer. To see your scale set in action, open this address in a web browser
68+
Get-AzPublicIpAddress -ResourceGroupName "myResourceGroup" | Select IpAddress
69+
```
70+
2471

2572
## Clean up deployment
2673
Run the following command to remove the resource group, scale set, and all related resources.

0 commit comments

Comments
 (0)