-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathARM - Virtual Machine (VM) - Configuration.ps1
60 lines (38 loc) · 1.33 KB
/
ARM - Virtual Machine (VM) - Configuration.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<# Virtul Machine - Configuration #>
# Variables - Virtul Machine
$vmShortName = "Test"
$vmSuffix = "VM"
$vmName = "${vmShortName}${vmSuffix}"
Get-AzureRmVM -Name $vmName -ResourceGroupName $rgName -ErrorVariable isVMExist -ErrorAction SilentlyContinue `
If (!$isVMExist)
{
Write-Output "Virtul Machine exist"
# IIS
Set-AzureRmVMExtension `
-VMName $vmName `
-ResourceGroupName $rgName `
-Location = $location `
-ExtensionName IIS `
-Publisher Microsoft.Compute `
-ExtensionType CustomScriptExtension `
-TypeHandlerVersion 1.4 `
-SettingString '{"commandToExecute":"powershell Add-WindowsFeature Web-Server; powershell Add-Content -Path \"C:\\inetpub\\wwwroot\\Default.htm\" -Value $($env:computername)"}' `
<#
# IIS - way 2 (In VM)
# Install IIS
Install-WindowsFeature -name Web-Server -IncludeManagementTools
# Remove default htm file
remove-item C:\inetpub\wwwroot\iisstart.htm
#Add custom htm file
Add-Content -Path "C:\inetpub\wwwroot\iisstart.htm" -Value $("Hello World from host" + $env:computername)
#>
}
Else
{
Write-Output "Virtul Machine does not exist"
}
<#
## References
# configure IIS
https://docs.microsoft.com/en-us/azure/application-gateway/application-gateway-create-gateway-arm
#>