Recycling an AppPool Remotely With PowerShell

0 Flares Twitter 0 Facebook 0 StumbleUpon 0 Google+ 0 LinkedIn 0 0 Flares ×

I had a requirement the other day to recycle an IIS app pool from a client machine on the network (just a convenience thing to be honest). Once again I decided to break out PowerShell to work out how this would be down – and I have to say it was pretty simple.

The key to getting this done is the Get-WMIObject and Invoke-WMIMethod commandlets.

The first thing I did to get this started was use the Get-WMIObject method to enumerate the IIS application pools – this gave me information about the path of the process I wanted to recycle:

Once I’d done this I found the app pool in the list output, and copied the name of it. My final script then looked something like this:

The first few lines are all pretty self explanatory, i.e. creating some variables to hold my server name, the app pool name and finally the app pool path. The final line is the actual call that recycles the application pool. Of course, if you wanted something in one line, and already knew your application pool path then you could use the following:

PowerShell is great!!!

, ,

The Essential App Marketing Kit
Subscribe To My Newsletter To Get an Entire Chapter From The Book for FREE
Never display this again
0 Flares Twitter 0 Facebook 0 StumbleUpon 0 Google+ 0 LinkedIn 0 0 Flares ×