Creating new IIS site and ERROR ( message:Failed to add duplicate collection element “yoursite”. )

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!

Creating new IIS site and ERROR ( message:Failed to add duplicate collection element “yoursite”. )