Skip to content

Instantly share code, notes, and snippets.

@jeppevammenkristensen
Created May 6, 2014 10:39
Show Gist options
  • Save jeppevammenkristensen/3c038b5bd9c10babac57 to your computer and use it in GitHub Desktop.
Save jeppevammenkristensen/3c038b5bd9c10babac57 to your computer and use it in GitHub Desktop.
Import-Module webadministration
$managedRuntime = "v4.0"
$Name = "Madplan"
# This is of cause a dependency on Powershell version 3.0
$webPath = join-path $PSScriptRoot $Name
Write-Host $webPath
pushd iis:\apppools
if (!(Test-Path $Name))
{
Write-Host "Requesting your password"
$credential = Get-Credential
Write-Warning "Adding app pool with your credentials $Name"
$apppool = New-item $Name
$apppool | Set-ItemProperty -Name "managedRuntimeVersion" -Value $managedRuntime
$apppool.processModel.identityType = 3
$apppool.processModel.username = $credential.GetNetworkCredential().UserName
$apppool.processModel.password = $credential.GetNetworkCredential().Password
#$apppool.processModel.setProfileEnvironment = $true
$apppool | Set-Item
}
popd
pushd iis:\sites
if (Test-Path $name){
return
}
if ($credential -eq $null){
$credential = Get-Credential
}
$iisApp = new-item $name -bindings @{protocol="http";bindingInformation=":80:" + "$Name.localtest.me"} -physicalPath $webPath
$iisApp | Set-ItemProperty -Name "applicationPool" -Value $Name
$iisApp | Set-ItemProperty -Name username -value $credential.GetNetworkCredential().UserName
$iisApp | Set-ItemProperty -Name password -value $credential.GetNetworkCredential().Password
popd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment