Forked from anderssonjohan/Install-ARRFromWeb.ps1
Last active
September 13, 2016 05:45
-
-
Save KennethanCeyer/8849a8534e342f9c6eb7952b302d2308 to your computer and use it in GitHub Desktop.
ARR Install script for AWS Beasntalk extension working on PowerShell. (This code working on AWS Beasntalk instance. (IIS 8.5, Windows 2012 RC2))
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
begin { | |
$TargetPath = $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath(‘.\’) | |
iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1')) | |
choco install curl | |
$packages = @( ` | |
@{ Name = "webfarm.msi"; Url = "https://download.microsoft.com/download/F/E/2/FE2E2E07-22B5-4875-9A36-8B778D157F91/WebFarm2_x64.msi" }, ` | |
@{ Name = "rewrite.msi"; Url = "https://download.microsoft.com/download/6/7/D/67D80164-7DD0-48AF-86E3-DE7A182D6815/rewrite_2.0_rtw_x64.msi" }, ` | |
@{ Name = "arr.msi"; Url = "https://download.microsoft.com/download/E/9/8/E9849D6A-020E-47E4-9FD0-A023E99B54EB/requestRouter_amd64.msi" } | |
) | |
Push-Location $env:TEMP | |
function download( $url, $filename ) { | |
if(!(Test-Path $filename) -or $force) { | |
curl -OutFile $filename $url | |
if( $LASTEXITCODE -ne 0 -or !(Test-Path $filename) ) { | |
Pop-Location | |
throw "Failed to download $url to $filename" | |
exit 1 | |
} | |
} | |
} | |
Write-Host "Downloading MSI packages..." | |
$packages | %{ | |
Write-Host ("Downloading MSI package: {0}" -f $_.Name) | |
download $_.Url $_.Name | |
} | |
} | |
process { | |
$remotePackageDir = join-path $TargetPath "\" | |
$packageNames = $packages | %{ $_.Name } | |
Write-Host "Copying packages to server: $packageNames" | |
$packageNames | cp -Destination $remotePackageDir | |
Write-Host "Done. Performing installation..." | |
#$Session = $targetHost.Connect() | |
Invoke-Command -ArgumentList $packageNames -ScriptBlock { | |
if( Get-Service was ) { | |
Write-Host "Stopping IIS and WAS..." | |
Stop-Service was -Force | |
} | |
Push-Location $targetHost.ScriptShareLocalPath | |
$args | %{ | |
Write-Host "Installing MSI package: $_" | |
$exitCode = (Start-Process -FilePath "msiexec" -ArgumentList "/q /i $_ /L*v install.log" -PassThru -Wait).ExitCode | |
#if( $exitCode -ne 0 ) { | |
# Pop-Location | |
# throw "MSIEXEC exited $exitCode Failed to install $_" | |
# exit 1 | |
#} | |
rm $_ | |
} | |
Pop-Location | |
if( Get-Service was ) { | |
Start-Service was,w3svc -Verbose | |
} | |
} | |
if( $? ) { | |
Write-Host "ARR installed!" | |
} else { | |
cp $remotePackageDir\install.log -Verbose | |
gc install.log | ?{ $_ -match "error|fail|requisite" } | |
} | |
} | |
end { | |
Pop-Location | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment