我試圖在部署在Azure中的網站的根目錄下配置web應用程序的serviceAutoStartEnabled和serviceAutoStartProvider屬性。如果我瞭解自動啓動過程,可以在單個網站下爲特定Web應用程序設置這些屬性。使用Powershell Web管理模塊獲取網站的根應用程序
我web角色啓動時執行PowerShell腳本(後提升的權限已經啓動任務獲得)來執行網絡管理任務如下所示:
write-host "Begin RoleStart.ps1"
import-module WebAdministration
Add-WindowsFeature NET-WCF-HTTP-Activation45,NET-WCF-TCP-Activation45,NET-WCF-Pipe-Activation45
$listenerService = Get-WmiObject win32_service -filter "name='NetPipeActivator'"
$listenerService.ChangeStartMode("Automatic")
$listenerService.StartService()
$WebRoleSite = (Get-WebSite "*web*")
$WebRoleSiteName = $WebRoleSite.Name
$WebRoleAppPool = $WebRoleSite.ApplicationPool
New-ItemProperty "IIS:/Sites/$WebRoleSiteName" -name bindings -value @{protocol="net.pipe";bindingInformation="*"}
Set-ItemProperty "IIS:/Sites/$WebRoleSiteName" -Name EnabledProtocols 'http,net.pipe'
Set-ItemProperty -Path "IIS:\AppPools\$WebRoleAppPool" -Name startMode -Value AlwaysRunning
write-host "End RoleStart.ps1"
這臺應用程序池了AlwaysRunning屬性,但我仍然需要爲應用程序特定的serviceAutoStartEnabled和serviceAutoStartProvider屬性提供新值。
我知道我可以使用Get-WebApplication的獲取應用程序和設定。但是這兩個屬性,當我運行下面的PowerShell命令我沒有看到根(「/」)應用程序的應用程序:
(Get-WebApplication "*") | format-list *
那麼如何使用webadministration cmdlet爲根應用程序設置這兩個屬性?