Copying an IIS Application Pool Using Powershell WebAdministration

I am trying to copy an existing IIS 7.5 application pool using the WebService Powershell module without stopping the application.

When I copy the application pool when I start and load the application, I get a NullReferenceException.

$pool = 'app1-0' $newpool = 'app1-1' cp "iis:/apppools/$pool" "iis:/apppools/$newpool" -force 

Output:

 Copy-Item : Object reference not set to an instance of an object. 

If I stop the pool or start the application pool and do not download the application, the copy command will complete successfully.

With the exception of copying properties one by one, is there a way to copy / clone a running and loaded application pool?

+4
source share
2 answers

Have you tried using appcmd instead?

Update: try a combination of both -

Perhaps the addition does not allow you to import and specify commands. You can try something like this:

 appcmd list appool thing1 /xml > c:\tempfile.xml (Get-Content c:\tempfile.xml).Replace("thing1", "thing2") | Out-File c:\tempfile2.xml appcmd add apppool /in < c:\tempfile2.xml 

You may need to debug the script a bit :)

+4
source

To export the application pool, use% windir% \ system32 \ inetsrv \ appcmd list apppool "AppPoolName" / config / xml> D: \ AppPoolConfig.xml

Without / config, you are missing all the options in the application pool, and when you switch to import, you will create a new application pool with the default application pool settings.

+2
source

All Articles