How to enable URL Rewrite module in IIS 8.5 on server 2012 using command line on first boot

Similar to the question: How to enable the "Rewrite URL" Module in IIS 8.5 on Server 2012? but via the command line.

I want to create a script to use on a UserData field in AWS (scripts that run on first boot to set up a server) and I was wondering how to set a Rewrite 2.0 URL via the command line or other elements of the web platform installer.

thank

+3


source to share


1 answer


I would use chocolatey for this. In fact, I have a set of functions that I use to make this easier. Save this script somewhere and call it from the UserData script:



<#
.description
Get the PATH environment variables from Machine, User, and
Process locations, and update the current Powershell
process PATH variable to contain all values from each of
them. Call it after updating the Machine or User PATH value
(which may happen automatically during say installing
software) so you don't have to launch a new Powershell
process to get them.
#>
function Update-EnvironmentPath {
    [CmdletBinding()] Param()
    $oldPath = $env:PATH
    $machinePath = [Environment]::GetEnvironmentVariable("PATH", "Machine") -split ";"
    $userPath    = [Environment]::GetEnvironmentVariable("PATH", "User")    -split ";"
    $processPath = [Environment]::GetEnvironmentVariable("PATH", "Process") -split ";"
    $env:PATH = ($machinePath + $userPath + $processPath | Select-Object -Unique) -join ";"
    Write-EventLogWrapper -message "Updated PATH environment variable`r`n`r`nNew value: $($env:PATH -replace ';', "`r`n")`r`n`r`nOld value: $($oldPath -replace ';', "`r`n")"
}

# Install Chocolatey itself:
Invoke-WebRequest https://chocolatey.org/install.ps1 -UseBasicParsing | Invoke-Expression
# NOTE: Chocolatey changes the system %PATH%, so we have to get the latest update here:
Update-EnvironmentPath
# Configure Chocolatey to not require confirmation when installing packages:
choco.exe feature enable --name=allowGlobalConfirmation --yes

# Install the package we care about
choco.exe install urlrewrite

      

+2


source







All Articles