简体   繁体   中英

appcmd.exe to overwrite a single site's entire xml config (applying the settings to a site that already exists)

I don't want to delete and recreate a site I just want to be able to apply the entire config to it and override any settings that are different.

I backed up the site config with %windir%\\system32\\inetsrv\\appcmd list site /config /xml > c:\\sites.xml

This command throws an error:

appcmd.exe add site /in < c:\sites.xml
ERROR ( message:Failed to add duplicate collection element "mysite". )

Do I really have to break out ALL of my IIS configuration into separate appcmd commands or is there a way to apply the entire xml in one shot and only have it override settings?

I want to have a single xml template that I can push out to all my webservers hosting this site.

If you already exists installed sites then you must by have other ID for new site

<SITE SITE.NAME="NewSite" SITE.ID="1094096085" bindings="*" state="Started">

        <site name="NewSite" id="1094096085" serverAutoStart="false">

Else you get conflict by ID

You should try shared config

http://www.iis.net/learn/manage/managing-your-configuration-settings/shared-configuration_264

Regarding:

 ERROR ( message:Failed to add duplicate collection element "mysite". )

It seems that you can not add a website that already exist.

Why dont you delete it and add it again with the new configurations?

You can also try to modify only the relevant sections.

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