问题/疑问Powershell的启动IIS网站
我试运行展鹏部署脚本。在最终的步骤启动一个网站:
import-module WebAdministration
$website = get-website | where-object { $_.name -eq $RedGateWebSiteName }
#(re)write HostName#
$binding = Get-WebBinding -Name $RedGateWebSiteName
Set-WebBinding -Name $RedGateWebSiteName -BindingInformation "*:80:*" -PropertyName HostHeader -Value $HostName
if ($website) {
Start-Website "$RedGateWebSiteName"
}
它总是工作,但现在的最后日子里,我得到这个错误一个
At D:\inetpub\Timeblockr-RedGate\Api\PostDeploy.ps1:15 char:15
+ Start-Website <<<< "$RedGateWebSiteName"
+ CategoryInfo : InvalidOperation: (:) [Start-Website], COMException
+ FullyQualifiedErrorId : InvalidOperation,Microsoft.IIs.PowerShell.Provider.StartWebsiteCommand
IIS错误
The World Wide Web Publishing Service (WWW Service) did not register the URL prefix http://*:80/ for site 3. The necessary network binding may already be in use. The site has been disabled. The data field contains the error number.
这太问题"Cannot create a file" error when running Start-Website command in Powershell给出了一个很好的线索。
编辑:
看我的事件日志,检查出我发现,当展鹏全自动尝试安装/启动网站我得到这个答案后IIS错误:
The World Wide Web Publishing Service (WWW Service) did not register the URL prefix http://*:80/ for site 3. The necessary network binding may already be in use. The site has been disabled. The data field contains the error number.
在这个服务器错误:https://serverfault.com/questions/456217/the-world-wide-web-publishing-service-www-service-did-not-register-the-url有人提到,其原因是IIS网站创建时没有hostheader。我尝试启动网站后添加了主机头。让我们找到解决方案
编辑2: 我试图启动网站后添加了主机名。这导致该网站有e空主机名,并在IIS中发生冲突。 (或者别的地方)。 我已更改我的脚本以获取网站,添加主机名,然后启动网站。 还增加了“的$RedgateWebsiteName"
代替$RedGateWebSiteName.
完美的作品现在
编辑3: 的测试运行后,我似乎结束了相同的错误的一个部署有没有问题,其他的部署,但这有
。编辑4: 我已经更新脚本/错误/后 我删除了我的网站从IIS之后,我点击安装完美安装 - 没有问题,自动启动 第二轮完全相同,。第三次运行我得到上面的错误!
你可以通过UI启动网站吗? –
@DavidMartin是的,这是完美的作品。 – JochemQuery