If you executed a command line to create a new website in IIS8 and encountered: ERROR ( message:Failed to add duplicate collection element “yoursite”. ) this is what fixed in my case.
After executing:
C:\windows\system32\inetsrv\appcmd.exe add site /name:YourSite /id:12 /bindings:"http/*:8099:" /physicalpath:E:\inetpub\yoursite
It errored out with the message above, and I thought that there is already a site with this name. Searing and googling and checking %windir%\system32\inetsrv\config\applicationHost.config I found nothing!
The problem was not the name it was the id!
/id:12
So if you have duplicate id the error is the same as duplicate name.
EDIT: Change the id with some unused number and you are good to go.
I hope this saves you time!
How do you fix it?
LikeLike
Just change the ID number. I’ve picked one that is not in use. If your command now is with let say /id:12 as in my example, make it 13 and try again. You can go and see all site IDs with IIS manager – one by one, but that’s more work.
Another option is to delete the site with the id that you are using but that is only viable if that site is obsolete, but again that depends on your case – it could be a different important site that you cannot delete.
Let me know if this helps 🙂
LikeLike
It actually saved me an afternoon of looking for an answer, I was afraid to delete default site Id 1, but it continue to work after setting it to a different id, I moved 14 sites, and around 100 apps with it. Thanks Nik!
LikeLike
Happy to hear that!
LikeLike
Still useful, thanks a lot!
LikeLike
saved my day!
LikeLike
Thanks 🙂 That worked
LikeLike
Thank you !!
LikeLike
Unfortunately, this didn’t work for me.
I am using inetsrv\appcmd add sites /in < "~\sites.xml" from an export
I made sure the ID's were all unique and they are. But I still get the error
LikeLike