-
Notifications
You must be signed in to change notification settings - Fork 90
/
Copy pathiis-with-webdeploy.ps1
28 lines (23 loc) · 1.45 KB
/
iis-with-webdeploy.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
# Install IIS (with Management Console)
Install-WindowsFeature -name Web-Server -IncludeManagementTools
# Install ASP.NET 4.6
Install-WindowsFeature Web-Asp-Net45
# Delete contents of wwwroot
Remove-Item -Recurse C:\inetpub\wwwroot\*
# Install Web Deploy 3.6
# Download file from Microsoft Downloads and save to local temp file (%LocalAppData%/Temp/2)
$msiFile = [System.IO.Path]::GetTempFileName() | Rename-Item -NewName { $_ -replace 'tmp$', 'msi' } -PassThru
Invoke-WebRequest -UseBasicParsing -Uri http://download.microsoft.com/download/0/1/D/01DC28EA-638C-4A22-A57B-4CEF97755C6C/WebDeploy_amd64_en-US.msi -OutFile $msiFile
# Prepare a log file name
$logFile = [System.IO.Path]::GetTempFileName()
# Prepare the arguments to execute the MSI
$arguments= '/i ' + $msiFile + ' ADDLOCAL=ALL /qn /norestart LicenseAccepted="0" /lv ' + $logFile
# Sample = msiexec /i C:\Users\{user}\AppData\Local\Temp\2\tmp9267.msi ADDLOCAL=ALL /qn /norestart LicenseAccepted="0" /lv $logFile
# Execute the MSI and wait for it to complete
$proc = (Start-Process -file msiexec -arg $arguments -Passthru)
$proc | Wait-Process
Get-Content $logFile
$msiFile = [System.IO.Path]::GetTempFileName() | Rename-Item -NewName { $_ -replace 'tmp$', 'zip' } -PassThru
Invoke-WebRequest -UseBasicParsing -Uri "https://csged50dd698631x4a14xa7d.blob.core.windows.net/scripts/ntmsSampleWebApp.zip" -OutFile $msiFile -verbose
Expand-Archive $msiFile C:\inetpub\wwwroot -verbose
#Done