36 lines
1.5 KiB
PowerShell
36 lines
1.5 KiB
PowerShell
# Backup existing applicationHost.config
|
|
copy C:\Windows\System32\inetsrv\config\applicationHost.config C:\Windows\System32\inetsrv\config\applicationHost_BeforeInstallingANCM.config
|
|
|
|
Import-Module IISAdministration
|
|
|
|
# Initialize variables
|
|
$aspNetCoreHandlerFilePath="C:\windows\system32\inetsrv\aspnetcore.dll"
|
|
Reset-IISServerManager -confirm:$false
|
|
$sm = Get-IISServerManager
|
|
|
|
# Add AppSettings section
|
|
$sm.GetApplicationHostConfiguration().RootSectionGroup.Sections.Add("appSettings")
|
|
|
|
# Set Allow for handlers section
|
|
$appHostconfig = $sm.GetApplicationHostConfiguration()
|
|
$section = $appHostconfig.GetSection("system.webServer/handlers")
|
|
$section.OverrideMode="Allow"
|
|
|
|
# Add aspNetCore section to system.webServer
|
|
$sectionaspNetCore = $appHostConfig.RootSectionGroup.SectionGroups["system.webServer"].Sections.Add("aspNetCore")
|
|
$sectionaspNetCore.OverrideModeDefault = "Allow"
|
|
$sm.CommitChanges()
|
|
|
|
# Configure globalModule
|
|
Reset-IISServerManager -confirm:$false
|
|
$globalModules = Get-IISConfigSection "system.webServer/globalModules" | Get-IISConfigCollection
|
|
New-IISConfigCollectionElement $globalModules -ConfigAttribute @{"name"="AspNetCoreModule";"image"=$aspNetCoreHandlerFilePath}
|
|
|
|
# Configure module
|
|
$modules = Get-IISConfigSection "system.webServer/modules" | Get-IISConfigCollection
|
|
New-IISConfigCollectionElement $modules -ConfigAttribute @{"name"="AspNetCoreModule"}
|
|
|
|
# Backup existing applicationHost.config
|
|
copy C:\Windows\System32\inetsrv\config\applicationHost.config C:\Windows\System32\inetsrv\config\applicationHost_AfterInstallingANCM.config
|
|
|