Category Archives: Windows Server 2008

Playing around with Microsoft.Web.Administration.dll

A few days ago, I needed a script to reset a specific application pool (IIS 7.0) and to force the compilation of the sites in this application pool by calling them with a http request. Unfortunately, Microsoft didn’t came up with a powershell snapin until the release of Windows 2008 R2 and IIS 7.5. If you want to administrate IIS 7.0 in an easy way with a managed DLL, you can use the Microsoft.Web.Administration.dll, which is installed along the Webserver Role. First you need to import the dll because it is not loaded by default:

After this command, you can create new objects from the Namespace Microsoft.Web.Administration. For our purpose, we need to create an Object from the ServerManager Class. After this, we need to define two variables, each one containig the application pools or the sites.

Now you can loop through the application pools and the sites. Below you see the complete script, which stops and starts an application pool and then makes a request on the sites running under this application pool. In this example, I assume that application pool and site have the same name. Looping through all application of all sites to check their application pool would be the better way. (I was lazy a this time, I know)

Then I use the static method DownloadString( $url ) to send the http request. The URL is combined by the sites binding (only works if you have only one specified IP binding on the site) and the application path.

Have fun…

mySQL dump script

For all the admins out there, which happen to manage a mySQL Server on a Win2k8 Server without Enterprise Support. Here you have a mySQL dump script for PSH with a simple version system. The version count can be set in the script…


Oh, and don’t forget to safe the dumps with a regular backup tool, e.g. Wbadmin…