Your basic ITPro blog... What's going on at work, what I'm interested in.

Wednesday, August 17, 2011

IIS7 Virtual Directory Reporting–Part II

My last post was on the topic of IIS Virtual Directory reporting in Powershell. The script worked well and gave me a nice little report that I could then send off to others in our Communications Department, for example, when requested. It wasn’t long after this that it was suggested that we build a webpage that generated this report. Then, our Communications Department could just go view the report for themselves.

Coincidentally, I have been working on improving my web development skills. So, I was asked if I wanted to try and tackle this task. I did and we came up with the following short list of features:

  • Report a list of current Virtual Directories and their httpRedirect – or “Friendly URL” – attributes.
  • Provide a QR Code for each Friendly URL.
  • Link to our Arena assignment page to Add/Change a Friendly URL.
  • FOR ME: A page to create/modify Friendly URLs.

My initial thoughts on how I would accomplish this included parsing the XML in web.config files, traversing physical folders, reading other .config files for the relevant data, etc. It seemed like it was going to be very complicated. Then, as I was researching this project further, I came across the magic that is the Microsoft.Web.Administration Namespace. As you can imagine (or already know if you are familiar with it), this made things MUCH simpler.

Now, I’m no developer (yet), but I am learning and hope to become somewhat proficient someday. I have two great friends, resources, and mentors in Nick and Jason here at Central. With their help, I am actually getting this project built. The goal is to implement it as an Arena module to leverage various Arena features.

I hope to have more to come in the near future as this project develops. It has been fun so far and I have already learned a ton… Mostly, I am learning just how much I DON’T know!

Wednesday, June 22, 2011

IIS7 Virtual Directory Reporting

WARNING: This post is bred out of ignorance. I don’t know much at all about IIS7 administration (it’s new to us) or the IIS7 Powershell cmdlets. Everything below is a result of web searches and trial-and-error. I am completely confident that there is a better and easier way to accomplish this stuff. I would love to hear about it! Thanks!


I got a request for a list of our virtual directories and their ‘HTTP Redirect’ settings on our web server. We are running IIS7. I knew that there is a Powershell module for IIS7 management – named ‘WebAdministration’ – so I figured that this would be an easy one-liner… something like:

- Get-WebVirtualDirectory | Select Name, HTTPRedirectDestination

Or something similar…

But, this did not work. After looking around for a while, it looks like the WebVirtualDirectory cmdlets don’t have any capacity to report on, or modify, these settings. Further, some of my vDirs had this information stored in a web.config file in their physical path location and some did not (was it in the IIS metabase?!). I would look at the web.config files of two vDirs that looked the same in the GUI and the web.config files would have totally different settings. I was getting very confused and frustrated.

But, I need this report so I needed a plan of attack. I settled on the following:

  • Get all vDir configurations to be consistent, using a web.config file.
    • Make sure each vDir has a unique physical path.
    • Make sure each vDir has a web.config file with the proper configuration items.
  • Write a Powershell script to list vDirs and pull the redirect destination information out of the web.config file.

To that end, I ended up with the following few lines of Powershell -

$hashTable = @{}

foreach ($virtualDirectory in Get-WebVirtualDirectory)
$vdName = $virtualDirectory.Path.Trim('/')
$vdPath = $virtualDirectory.physicalPath
$webConfig = $vdPath + "\web.config"
$webConfigXML = [xml](Get-Content $webConfig)
$redirectDestination = $webConfigXML.configuration.FirstChild.httpRedirect.destination

$hashTable[$vdName] = $redirectDestination

$hashTable.GetEnumerator() | Sort Name
From here, I just Out-File the script results to a text file and send the report off. Functional, I guess.
UPDATE: I updated this script a bit to add a little more information to the output. I also changed the output object from a hashtable.
$vDirs = @()

foreach ($virtualDirectory in Get-WebVirtualDirectory)
$vdName = $virtualDirectory.Path.Trim('/')
$vdPath = $virtualDirectory.physicalPath
$webConfig = $vdPath + "\web.config"
$webConfigXML = [xml](Get-Content $webConfig)
$redirectDestination = $webConfigXML.configuration.FirstChild.httpRedirect.destination
$vdCreationDate = (Get-ChildItem $vdPath).CreationTime #.ToShortDateString()

$obj = New-Object object
Add-Member -InputObject $obj -MemberType NoteProperty -Name "Name" -Value $vdName
Add-Member -InputObject $obj -MemberType NoteProperty -Name "RedirectDestination" -Value $redirectDestination
Add-Member -InputObject $obj -MemberType NoteProperty -Name "CreationDate" -Value $vdCreationDate

$vDirs += $obj


Monday, May 9, 2011

Test Lab!

So, this is something I have been wanting to do for a long time. Being able to ‘play’ with new technology is a huge benefit in my industry and job.

With our virtualization environment being as robust as it is now, we have some headroom and the ability to put a small lab environment in place. So, I have used this guideline to create a base lab environment.

Looking forward to using this to explore new technologies.

Tuesday, April 26, 2011

Managing IIS

If you have to manage IIS servers and environments, and you are not watching this video series, you are missing out!

Thank you, Scott Forsyth!

Tuesday, February 15, 2011

Hyper-V Cluster Is IN!

So, the work is complete… Well, this sort of work is never really complete, per se. But, our Hyper-V cluster project is complete enough to call it complete. Make sense?

I have blogged about this saga before, so I’m not going to go into every nitty-gritty detail. But, here is an overview of what we did.


  • 2 x Hyper-V hosts in production.
  • MD3000i iSCSI SAN providing storage to Hyper-V hosts.
  • Virtual Machine Manager used (primarily) for management of Hyper-V hosts.


  • 3 x Clustered Hyper-V hosts
  • MD3000i iSCSI SAN providing CSV storage to cluster.
  • Virtual Machine Manager still being used to manage the environment.
  • 1 x 5TB DAS to be re-deployed as storage for our Worship Arts department.


  • Brought up a third Hyper-V Host server and attached DAS and SAN.
  • Migrated ALL of our VMs onto this one host (scary!!).
  • Reinstalled Win2008R2 on original two hosts.
  • Created a two-node cluster with these hosts, using the SAN to provide CSVs.
  • Migrated all VMs off the interim Hyper-V host and into the cluster.
  • Added interim host as a third node in the cluster.
  • Tested fail-over, fail-back, Live Migration, etc. etc. etc.
  • Sat quietly for a moment, very pleased with the outcome.


  • This was my first experience with clustering. It could not have been easier.
  • Getting a Hyper-V pass-through disk into a cluster was not as daunting as I was expecting. Just make sure you know of the limitations, caveats, and oddities.
  • I like VMM, though I still find I have to go into Hyper-V Manager and Cluster Manager for some things. It’s rare though, which is nice.
  • I wish fail-back in the cluster would use Live Migration, rather than Quick Migration. Maybe I’m missing something here.
  • I love being able to do maintenance on my Hyper-V hosts without having to ‘down’ my VMs. This is huge!
  • Now that our environment has it, I want to maintain an N+1 type environment.
  • I sure could use a 4th node in my cluster! And a 5th…
  • BackupExec 2010 works really well with the Hyper-V cluster. Yes, the agents aren’t cheap, but what is your data/environment worth?!

During this project, I hit a few snags here and there. Luckily, someone invented the Internets a while ago, so every answer I needed was only one Google search away!

Lastly, I am looking forward to SP1 that should, from what I have read, give me memory-oversubscribe and a few other cool updates.

Friday, January 28, 2011

Clustered Hyper-V Environment

I got to work on this project this week. We had three discreet Hyper-V hosts. I moved all of our VMs onto one of the hosts, turning off non-essential VMs and minimizing resource usage as I could to make them all fit. Once the other tow VM host machines were empty, I re-installed the OS (Windows 2008 R2 DCE), created a failover cluster, configured CSVs, etc. and got these machines ready to host HA VMs.

I have been testing failover, live migration, etc. Things are working great! Once I have all of the VMs on the cluster, I will add the third host into the cluster, giving me a great VM hosting environment.

This project has been on my front-burner for quite a while. It is great being in the last stages of it now!

One last note, if you aren’t using SCVMM to manage your Hyper-V virtualization environment… well… you’re doing it wrong!  Smile

Here is my ‘plan’ that I followed for this project.



  1. How To
  2. Pass-through Disk in a cluster
  3. Hyper-V Cluster and VMM08
  4. Error With Live Migration


  1. 1Gb – Cluster Quorum Disk
  2. 3 x big - CSV volumes


  1. Move all VMs onto temporary VM host – VMH00
  2. Change Host Type of VMH04 and VMH05 from non-clustered to clustered
  3. Create 1GB virtual disk to use as quorum disk for cluster
  4. Create Host Group in MDSM (added VH04 and VMH05 to host group)
  5. Disconnected VM storage virtual disk from VMH05 and renamed to ‘CSV01’
  6. Upgrade OS on VMH05 to Win2008R2DCE
    1. Remove Hyper-V role
    2. Add “Desktop Experience” feature to get to disk cleanup tool
      1. Required to free up space to do the OS upgrade
    3. Can’t upgrade OS. Need to do a new install. Can it be done from the R2 disk? YES!
      1. Install OS into new partition – blow out old partition
      2. IP address
      3. Name and domain (VMH01, was VMH05)
      4. Add features – SNMP, Failover Clustering, Desktop Experience, MPIO
      5. Add roles - File Services, Hyper-V
    4. Intel VT 1000 Quad Port NIC Drivers
    5. Install Dell MD software
    6. Configure iSCSI Initiator
  7. Configure Hyper-V networking identical on both VMH machines
  8. Make virtual disks available to both hosts for VM storage
    1. On VMH01
      1. Use iSCSI Initiator to connect to Virt Disks
      2. User Server Manager|Disk Management to configure Virtual disks for access (initialize, partition, format, etc.)
      3. Take disks offline (not sure if needed)
    2. On VMH02
      1. Use iSCSI Initiator to connect to both Virt Disks
      2. ONLY USE Disk Management to rescan for disks
  9. Use Server Manager to install Failover Cluster Feature
    1. On both hosts!
  10. Open Failover Cluster Manager (in Administrative Tools on VMH01)
    1. Validate configuration, using both cluster node names, run all tests
    2. Remediate issues as needed
    3. Create the Cluster
      1. Select “Create a Cluster” from action menu
      2. Add both cluster nodes
      3. Cluster name
      4. Cluster IP address – fixed IP
      5. Select cluster in navigation pane
      6. “Enable Cluster Shared Volumes” in action pane
      7. Read notice and click OK
    4. Select ‘Cluster Shared Volumes’ in the navigation pane
      1. “Add Storage” from action pane
      2. Select the big disks used for VM storage
  11. Open Hyper-V Manager on both Cluster nodes
    1. Select ‘Hyper-V Settings’ in the action pane
    2. Enter new directory locations –
      1. Examples:
        1. C:\ClusterStorage\Volume1\Hyper-V\Virtual Hard Disk (VHDs)
        2. C:\ClusterStorage\Volume1\Hyper-V (VMs)
  12. Add HyperVCluster to VMM08
  13. Configure storage locations in VMM to point to all CSV resources
  14. If not using VMM
    1. Migrate a non-essential VM from VMH00 onto a cluster host, using cluster storage for the VM
    2. Shut down VM
    3. Open Failover Cluster Manager on the VM host that holds the VM
      1. Under Cluster Name, select “Services and Applications” node
      2. “Configure a service or application” in the action pane
        1. Select Virtual Machine – NEXT
        2. Select VM that was imported – NEXT – NEXT – FINISH
      3. Right-click the VM and select START
      4. To live-migrate –
        1. Select the VM
        2. “Live Migrate…” from action pane
        3. Select available cluster node (VMH05)
  15. Test migration, etc. in VMM.
    1. Was getting an error with Live Migration. Had to disable cluster communication on the iSCSI networks. Cluster communication only allowed on the LAN network.
    2. Set VM processor for ‘allow migration to VM host with a different processor’
    3. Make sure “Enable virtual network optimizations’ is NOT checked
  16. Move other VMs from VMH00 into the cluster.
  17. Once VMH00 is empty of VMs, add VMH00 to cluster.

Additional Info

My photo
email: support (AT) mangrumtech (DOT) com
mobile: 480-270-4332