简体   繁体   中英

Changing IIS bindings with PowerShell

I was looking to move web binding port from one site to another using PowerShell on Windows 21012 R2.

After looking online I found the command

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

Now the command is from a MS blog but everytime I run the command I get the following error.

WARNING: Target configuration object '/system.applicationHost/sites/site[compare-string-ordinal(@name,'work',true())=0]/bindings/binding[(@protocol='http' or @protocol='https') and compare-string-ordinal(@bindingInformation,'*:80:',true())=0] is not found at path 'MACHINE/WEBROOT/APPHOST'

Now for the life of me cannot understand why it's not finding the site "work":

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

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

These are clean sites created by PowerShell that also creates an application pool of the same name.

I had the same issue but this is how I fixed it:

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

The -BindingInformation should be the same as what you see with the Get-WebBinding command.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM