使用PowerShell更改IIS绑定

时间:2018-01-30 07:56:57

标签: powershell iis windows-server-2012-r2

我希望在Windows 21012 R2上使用PowerShell将Web绑定端口从一个站点移动到另一个站点。

在线查看后,我找到了命令

Set-WebBinding -Name 'work' -BindingInformation "*:80:" -PropertyName Port -Value 1234

现在命令来自MS博客,但每次运行命令时都会出现以下错误。

  

警告:目标配置对象'/system.applicationHost/sites/site[compare-string-ordinal(@name,'work',true())=0]/bindings/binding[(@protocol='http'或@ protocol ='https')并且在路径'MACHINE / WEBROOT / APPHOST'中找不到compare-string-ordinal(@ bindingInformation,'*:80:',true())= 0]

现在我的生活无法理解为什么它没有找到网站“工作”:

PS C:\Windows\system32> Get-WebBinding -Port 80 -Name "work"

protocol        bindingInformation        sslFlags
--------        ------------------        --------
http            :80:work                         0

这些是PowerShell创建的干净站点,它们还创建了一个同名的应用程序池。

1 个答案:

答案 0 :(得分:0)

我遇到了同样的问题,但这是我解决的方法:

Set-WebBinding -Name 'work' -BindingInformation ":80:" -PropertyName Port -Value 1234

-BindingInformation应该与您在Get-WebBinding命令中看到的相同。