Blog reboot!

A reboot solves many problems…

…my last entry of this blog was about three or four years ago and even those articles have been imported from my old Google Blog.

I decided to give this blog a reboot and I plan to write a least every month an entry about modern technologies and its problems and solutions.

Stay tuned…

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…

Enjoy!

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

Change NTFS security on some folders

Everyone working in IT stumbled over the cursed problem, to change the ACL on a set of folders or files.

First you define the folder or the file(s) to be changed.

Then you collect the filesystem objects from the path variable with the following command.

The following foreach-loop reads the acl for every item in the target list. Then the permission for the additional acl is defined and with a .NET object it will be converted to an access rule.

The new access rule is added to the acl object and the object itself will be piped back to the item with the Set-Acl cmdlet.

So, have fun and be sure you always have a backup from the acl of your files, before you start messing around with this script.

Test open port with powershell

Once on a Windows 2008 Server without a telnet client installed, I tried to test a connection on a specific port.

After a few Google researches, I found a neat little powershell script to test a port with powershell:

Connect with the following method to a specific host with the port of your desire:

You can now check the property $sock.Connected, whether the connection was successfully or not:

Powershell and Citrix Metaframe COM Objects

Whenever you want to have a quick overview of the sanity of a XenApp 5 farm, you can use Powershell to retrieve useful infos from the Metaframe COM object. With XenApp 6 you have a bunch of Cmdlets to administrate and control your farm.

For XenApp 5 there are actually only the XenApp Commands available which are still only a tech preview. So if you want a stable and comfy environment to work with your farm, just create an COM object and use this instead.

With those two lines you will be able to access some very nice functions:

If you want to logoff all users on the farm, use the following line (this will log you out too if you are connected over rdp or ica):

Have fun…