-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsetup_iis.ps1
81 lines (67 loc) · 2.86 KB
/
setup_iis.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#Requires -RunAsAdministrator
param(
[string] $siteName = "mfepoc.rgbco.uk"
)
$ErrorActionPreference = "Stop"
Import-Module WebAdministration
Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Force
function Unzip($folder) {
$zipFile = "$folder\publish.zip"
if (Test-Path $zipFile) {
Write-Host "unziping $zipFile"
Expand-Archive -Path $zipFile -DestinationPath $folder -Force
if (Test-Path "$folder\publish_unzipped.zip") {
Remove-Item "$folder\publish_unzipped.zip" -Force
}
Rename-Item -Path $zipFile -NewName "publish_unzipped.zip"
}
}
function SetupSite($siteName, $path) {
$sitePool = Get-IISAppPool -Name $siteName
if ($sitePool -eq $null) {
Write-Host "Creating IIS pool $siteName"
Reset-IISServerManager -Confirm:$False
New-WebAppPool -Name $siteName
}
$site = Get-IISSite -Name $siteName
if ($site -eq $null) {
Write-Host "Creating IIS site $siteName"
Reset-IISServerManager -Confirm:$False
New-IISSite -Name $siteName -PhysicalPath $path -BindingInformation "*:80:$siteName"
}
Set-ItemProperty "IIS:\Sites\$siteName" -Name "PhysicalPath" -Value $path
Set-ItemProperty "IIS:\Sites\$siteName" -Name "applicationPool" -Value $siteName
Set-ItemProperty "IIS:\AppPools\$siteName" -Name recycling.disallowOverlappingRotation -Value True
Set-ItemProperty "IIS:\AppPools\$siteName" -Name "processModel.identityType" -Value 0
}
function SetupApp($siteName, $appName, $path) {
$poolName = "$siteName.$appName"
$pool = Get-IISAppPool -Name $poolName
if ($pool -eq $null) {
Write-Host "Creating IIS pool $poolName"
Reset-IISServerManager -Confirm:$False
New-WebAppPool -Name $poolName
}
$app = Get-WebApplication -Site $siteName -Name $appName
if ($app -eq $null) {
Write-Host "Creating app $appName"
Reset-IISServerManager -Confirm:$False
New-WebApplication -Site $siteName -Name $appName -PhysicalPath $path
}
Set-ItemProperty "IIS:\Sites\$siteName\$appName" -Name "applicationPool" -Value $poolName
Set-ItemProperty "IIS:\AppPools\$poolName" -Name "recycling.disallowOverlappingRotation" -Value True
Set-ItemProperty "IIS:\AppPools\$poolName" -Name "processModel.identityType" -Value 0
}
Unzip "home"
Unzip "generation"
Unzip "mixing"
Unzip "sales"
Unzip "reporting"
Unzip "dashboard"
Reset-IISServerManager -Confirm:$False
SetupSite $siteName "$((Get-Location).Path)\home"
SetupApp $siteName "Generation" "$((Get-Location).Path)\generation"
SetupApp $siteName "Mixing" "$((Get-Location).Path)\mixing"
SetupApp $siteName "Sales" "$((Get-Location).Path)\sales"
SetupApp $siteName "Reporting" "$((Get-Location).Path)\reporting"
SetupApp $siteName "Dashboard" "$((Get-Location).Path)\dashboard"