Search
Home IIS.NET Forums IIS 7 & IIS 8 Configuration & Scripting Any way to copy apppool settings from another apppool?
Last post Dec 09, 2010 03:04 PM by kloinerFeigling83
10 Posts
Dec 06, 2010 04:02 PM|LINK
In our staging and deployment procedures I want to do something like this:
appcmd list apppool /name:SourceApppool -xml /config:* | appcmd set apppool /name:TargetApppool -in
Obviously in the hope appcmd will be intelligent enough not to overwrite the name of the target apppool! However the result I get is this:
APPPOOL object "TargetApppool" changed ERROR ( hresult:800700b7, message:Failed to commit configuration changes. Cannot create a file when that file already exists. )
If this is not supported then my only option is to copy each setting separately?
appcmd configuration
118 Posts
Dec 06, 2010 07:03 PM|LINK
you can copy an app-pool like this if testapp3 isn´t existing: copy IIS:\AppPools\test IIS:\AppPools\testapp3 -force
but in order to copy settings i would run a script to set the properties, the API is pretty mighty...
maybe something like that: #webappPool [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.Web.Administration") $iis = new-object Microsoft.Web.Administration.ServerManager $iis.ApplicationPools["test"] $iis.ApplicationPools["testapp2"] $iis.ApplicationPools["testapp2"].childelements #$iis.ApplicationPools["testapp2"].childelements["processModel"] #$iis.ApplicationPools["testapp2"].childelements["processModel"].attributes #$iis.ApplicationPools["testapp2"].childelements["processModel"].attributes["username"].value #$iis.ApplicationPools["testapp2"].childelements["cpu"].attributes["resetinterval"].value $iis.ApplicationPools["testapp2"].childelements["processModel"].attributes["username"].value = $iis.ApplicationPools["test"].childelements["processModel"].attributes["username"].value $iis.CommitChanges()
Dec 09, 2010 08:45 AM|LINK
Thanks, but what processor is your copy command meant for? If I try it at a cmd prompt it gives:
E:\>copy IIS:\AppPools\test IIS:\AppPools\testapp3 IIS:\AppPools\test The filename, directory name, or volume label syntax is incorrect. 0 file(s) copied.
Dec 09, 2010 03:04 PM|LINK
sorry, i forgot to add that for powershell:
"import-moduule Webadministration"!
copy is an alias for copy-item
SaintNick
10 Posts
Any way to copy apppool settings from another apppool?
Dec 06, 2010 04:02 PM|LINK
In our staging and deployment procedures I want to do something like this:
appcmd list apppool /name:SourceApppool -xml /config:* | appcmd set apppool /name:TargetApppool -in
Obviously in the hope appcmd will be intelligent enough not to overwrite the name of the target apppool! However the result I get is this:
APPPOOL object "TargetApppool" changed
ERROR ( hresult:800700b7, message:Failed to commit configuration changes.
Cannot create a file when that file already exists.
)
If this is not supported then my only option is to copy each setting separately?
appcmd configuration
kloinerFeigl...
118 Posts
Re: Any way to copy apppool settings from another apppool?
Dec 06, 2010 07:03 PM|LINK
you can copy an app-pool like this if testapp3 isn´t existing:
copy IIS:\AppPools\test IIS:\AppPools\testapp3 -force
but in order to copy settings i would run a script to set the properties, the API is pretty mighty...
maybe something like that:
#webappPool
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.Web.Administration")
$iis = new-object Microsoft.Web.Administration.ServerManager
$iis.ApplicationPools["test"]
$iis.ApplicationPools["testapp2"]
$iis.ApplicationPools["testapp2"].childelements
#$iis.ApplicationPools["testapp2"].childelements["processModel"]
#$iis.ApplicationPools["testapp2"].childelements["processModel"].attributes
#$iis.ApplicationPools["testapp2"].childelements["processModel"].attributes["username"].value
#$iis.ApplicationPools["testapp2"].childelements["cpu"].attributes["resetinterval"].value
$iis.ApplicationPools["testapp2"].childelements["processModel"].attributes["username"].value = $iis.ApplicationPools["test"].childelements["processModel"].attributes["username"].value
$iis.CommitChanges()
SaintNick
10 Posts
Re: Any way to copy apppool settings from another apppool?
Dec 09, 2010 08:45 AM|LINK
Thanks, but what processor is your copy command meant for? If I try it at a cmd prompt it gives:
E:\>copy IIS:\AppPools\test IIS:\AppPools\testapp3
IIS:\AppPools\test
The filename, directory name, or volume label syntax is incorrect.
0 file(s) copied.
kloinerFeigl...
118 Posts
Re: Any way to copy apppool settings from another apppool?
Dec 09, 2010 03:04 PM|LINK
sorry, i forgot to add that for powershell:
"import-moduule Webadministration"!
copy is an alias for copy-item