Write-Host
"Adding the handler mapping..."
[System.Reflection.Assembly]::LoadFrom(
"C:\windows\system32\inetsrv\Microsoft.Web.Administration.dll"
)
$isapiPath
=
"C:\Program Files\Microsoft SQL Server\MSAS10_50.MSSQLSERVER\OLAP\bin\isapi\msmdpump.dll"
$isapiConfiguration
= Get
-WebConfiguration
"/system.webServer/security/isapiCgiRestriction/add[@path='$isapiPath']/@allowed"
if (
-not
(
$isapiConfiguration
-eq
$null
-or
$isapiConfiguration
.value))
{
Write-Host
"Enabling ISAPI Module - $isapiPath"
Set
-WebConfiguration
"/system.webServer/security/isapiCgiRestriction/add[@path='$isapiPath']/@allowed"
-value
"True"
-PSPath
:IIS:\
}
$serverManager
=
New-Object
Microsoft.Web.Administration.ServerManager
if (
$isapiConfiguration
-eq
$null
)
{
Write-Host
"Adding and enabling ISAPI Module - $isapiPath"
$appHostConfig
=
$serverManager
.GetApplicationHostConfiguration();
$isapiCgiRestrictionSection
=
$appHostConfig
.GetSection(
"system.webServer/security/isapiCgiRestriction"
);
$isapiCgiRestrictionCollection
=
$isapiCgiRestrictionSection
.GetCollection();
$cgiRestrictionElement
=
$isapiCgiRestrictionCollection
.CreateElement(
"add"
);
$cgiRestrictionElement
.SetAttributeValue(
"path"
,
"C:\Program Files\Microsoft SQL Server\MSAS10_50.MSSQLSERVER\OLAP\bin\isapi\msmdpump.dll"
);
$cgiRestrictionElement
.SetAttributeValue(
"allowed"
,
"true"
);
$cgiRestrictionElement
.SetAttributeValue(
"groupId"
,
""
);
$isapiCgiRestrictionCollection
.AddAt(0,
$cgiRestrictionElement
);
}
$webConfig
=
$serverManager
.GetWebConfiguration(
"Default Web Site"
,
"OLAP"
);
$handlersSection
=
$webConfig
.GetSection(
"system.webServer/handlers"
);
$handlersCollection
=
$handlersSection
.GetCollection();
$handlerElement
=
$handlersCollection
.CreateElement(
"add"
);
$handlerElement
.SetAttributeValue(
"name"
,
"OLAP"
);
$handlerElement
.SetAttributeValue(
"path"
,
"msmdpump.dll"
);
$handlerElement
.SetAttributeValue(
"verb"
,
"*"
);
$handlerElement
.SetAttributeValue(
"modules"
,
"IsapiModule"
);
$handlerElement
.SetAttributeValue(
"scriptProcessor"
,
"C:\Program Files\Microsoft SQL Server\MSAS10_50.MSSQLSERVER\OLAP\bin\isapi\msmdpump.dll"
);
$handlersCollection
.AddAt(0,
$handlerElement
);
$serverManager
.CommitChanges();