Powershell启动网站IIS
问题/问题 我正在测试运行redgate部署的脚本。在最后一步,它会启动一个网站:Powershell启动网站IIS,iis,powershell,redgate,Iis,Powershell,Redgate,问题/问题 我正在测试运行redgate部署的脚本。在最后一步,它会启动一个网站: import-module WebAdministration $website = get-website | where-object { $_.name -eq $RedGateWebSiteName } #(re)write HostName# $binding = Get-WebBinding -Name $RedGateWebSiteName Set-WebBinding -Name $RedGa
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
这个问题给出了一个很好的线索
编辑: 查看我的事件日志并查看答案后,我发现当Redgate自动尝试安装/启动网站时,我遇到以下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.
在这个Serverfault中:有人提到,原因是创建IIS网站时没有hostheader。我在尝试启动网站后添加hostheader。让我们找到解决办法
编辑2:
我在尝试启动网站后添加了主机名。这导致网站的主机名为空,并且IIS中存在冲突。(或其他地方)。
我已更改脚本以获取网站,添加主机名,然后启动网站。
还添加了“$RedgateWebsiteName”
而不是“$RedgateWebsiteName”。
现在工作得很好
编辑3:
经过一系列测试后,我似乎也犯了同样的错误。一个部署没有问题,另一个部署没有问题
编辑4:
我已经更新了脚本/错误/帖子。
单击“安装”后,我从IIS中删除了我的站点。安装完美-无问题,自动启动。
第二次运行完全相同,第三次运行我得到上面的错误 我猜$RedGateWebSiteName变量没有被赋值,假设日志消息用它的“值”替换变量。通过谷歌搜索,似乎IIS“文件已存在”消息可能是错误的,因为从丢失的IP地址绑定到无效的虚拟目录文件夹都可能是错误的。为什么需要脚本来启动网站?如果您使用的是Red Gate Deployment Manager,它会在部署web包(包含web.config文件的任何包)后启动网站 可能是$RedGateWebSiteName的值替换未发生,可能需要双引号: 启动网站“$RedGateWebSiteName” 我之所以这样说,是因为您的错误消息说:
启动网站我在启动网站时遇到了完全相同的问题:
Start-Website -Name MyWebSiteName
它不会启动。当我试图在IIS管理器中手动启动它时,它也不会启动,我收到以下错误消息:
The World Wide Web Publishing Service (W3SVC) is stopped. Websites cannot be started unless the World Wide Web Publishing Service (W3SVC) is running.
很明显,该服务没有启动,事实证明是真的。你能通过UI启动网站吗?@DavidMartin是的,效果很好。你是否尝试过检查系统的应用程序事件日志,以查看网站没有启动是否有有效的原因?谢谢你的回答,我尝试了放置“”围绕它,然后结果是开始网站
The World Wide Web Publishing Service (W3SVC) is stopped. Websites cannot be started unless the World Wide Web Publishing Service (W3SVC) is running.