Created
May 14, 2015 18:09
-
-
Save simplyadrian/69ecf7d78c9b4cdf1c77 to your computer and use it in GitHub Desktop.
Creates a virtual application in a IIS website
This file contains 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
# Powershell 2.0 | |
if($env:RS_REBOOT){exit 0} | |
# Stop and fail script when a command fails. | |
$errorActionPreference = "Stop" | |
# load library functions | |
$rsLibDstDirPath = "$env:rs_sandbox_home\RightScript\lib" | |
. "$rsLibDstDirPath\tools\PsOutput.ps1" | |
. "$rsLibDstDirPath\tools\ResolveError.ps1" | |
. "$rsLibDstDirPath\win\Services.ps1" | |
. "$rsLibDstDirPath\win\IIS.ps1" | |
try | |
{ | |
Import-Module WebAdministration | |
#$dest_dir = Join-Path $env:DIRECTORY_PATH $env:IIS_APP_NAME | |
if ( !(Test-path $env:VIRTUAL_DIRECTORY_PATH)) | |
{ | |
New-Item -ItemType directory -Path $env:VIRTUAL_DIRECTORY_PATH | |
} | |
# Create application for Identity | |
$web_app = Join-Path -Path IIS:\Sites\${env:IIS_APP_NAME} -ChildPath $env:VIRTUAL_APP | |
New-Item $web_app -physicalPath $env:VIRTUAL_DIRECTORY_PATH -type Application | |
Set-ItemProperty $web_app -name applicationPool -value $env:IIS_APP_POOL_NAME | |
Write-Host "The virtual directory $env:VIRTUAL_APP has been added to $env:IIS_APP_NAME" | |
#Modify application authentication methods | |
$siteName = "$env:IIS_APP_NAME/$env:VIRTUAL_APP" | |
$authentications = Get-WebConfiguration ` | |
-filter "system.webServer/security/authentication/*" ` | |
-PSPath $web_app | |
foreach ($auth in $authentications) | |
{ | |
$auth.SectionPath -match "/windowsAuthentication$" | |
$enable = ($matches.count -gt 0) | |
Set-WebConfigurationProperty ` | |
-filter $auth.SectionPath ` | |
-name enabled -value false -PSPath "IIS:\" -location $siteName | |
} | |
Set-WebConfigurationProperty -filter "/system.webServer/security/authentication/digestAuthentication" -name enabled -value true -PSPath IIS:\Sites\ -location "$env:IIS_APP_NAME/$env:VIRTUAL_APP" | |
Write-Host "Modification of the security authentication completed. Windows Authentication and Digest Authentication has been enabled for the Identity app." | |
} | |
catch | |
{ | |
ResolveError | |
exit 1 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment