From the MVPs: Hyper-V Blitz (hv_blitz) Inventory Tool

Here’s the 17th post in our series of guest posts by Microsoft Most Valued Professionals (MVPs). (Click the “MVPs” tag in the right column to see the rest.) Since the early 1990s, Microsoft has recognized technology champions around the world with the MVP Award. MVPs freely share their knowledge, real-world experience, and impartial and objective feedback to help people enhance the way they use technology. Of the millions of individuals who participate in technology communities, around 4,000 are recognized as Microsoft MVPs. You can read more original MVP-authored content on the Microsoft MVP Award Program Blog.

This post is by Nathan Lasnoski, a Microsoft Virtualization MVP.

Nathan here. A key aspect of Microsoft’s private cloud strategy is enabling standardization and automation. The extensive presence of PowerShell throughout Windows Server 2012 represents Microsoft’s commitment to these goals. The PowerShell capabilities can be used for both retrieval of data and the instantiation of action. These two capability sets provide the administrator both a comfortable user experience and a platform for technology automation.

I believe that community involvement is the answer to creating great tools. In an effort to move the community toward a collaborative goal, I’ve created a PowerShell script called “hv_blitz”. This bears relation in name and intended function to the great “sp_blitz”. The goal of hv_blitz is to gather Hyper-V host inventory and output it either to CSV or to the console in a method as fast as possible. I’ve found that this tool is very useful as a consultant because it requires no infrastructure and is fast to run. Here is the 1.0 version of hv_blitz.

#Hyper-V Blitz 
#Version 1.0
#Author: Nathan Lasnoski
foreach ($ComputerName in $args)
    Write-Host " "
    Write-Host "***************************"
    Write-Host "Hyper-V Host Configurations"
    Write-Host "***************************"
    $Hosts = Get-VMHost -ComputerName $ComputerName
    $Hosts | ft Name, LogicalProcessorCount, MemoryCapacity, ExternalNetworkAdapters -Auto
    Get-VMHost -ComputerName $ComputerName | Export-CSV -Path Hosts.csv
    Write-Host "Hyper-V Virtual Machines"
    $VMs = Get-VM -ComputerName $ComputerName
    $VMs | ft –Auto

Get-VM -ComputerName $ComputerName | Export-CSV VMs.csv
  Write-Host "************"
  Write-Host "Hyper-V VHDs"
  Write-Host "************"
  Write-Host " "
  foreach($VM in $VMs)
    $VHDs = Get-VHD -VMId $VM.VMiD -ComputerName $ComputerName 
    $VHDsGB = [math]::truncate($VHDs.FileSize / 1MB)
    Write-Host $VM.Name, $VHDs.Path, $VHDsGB "(MB)" | ft -Auto
    Write-Host " "
    $VHDs | Export-CSV VHDs.csv
  Write-Host " "
  Write-Host "************"
  Write-Host "Hyper-V Snapshots"
  Write-Host "************"
  Write-Host " "
  $Snapshots = Get-VM -ComputerName $ComputerName | Get-VMSnapshot
  $Snapshots | ft -Auto
  Get-VM -ComputerName $ComputerName | Get-VMSnapshot | Export-CSV Snapshots.csv
  Write-Host "****************"
  Write-Host "Hyper-V Switches"
  Write-Host "****************"
  Write-Host " "
  $Switches = Get-VMSwitch -ComputerName $ComputerName
  $Switches | ft -Auto
  Get-VMSwitch -ComputerName $ComputerName | Export-CSV .\Switches.csv
  Write-Host "****************"
  Write-Host "Hyper-V Replication Settings"
  Write-Host "****************"
  Write-Host " "
  Get-VM -ComputerName $ComputerName | ft Name, ReplicationState

Here is the output:


You can download hv_blitz at

In addition to getting settings from existing VMs, you can also implement new policies. For instance, in our hv_blitz output we’re seeing that a number of snapshots exist that haven’t been merged. If we wanted to merge those changes, we can

“Get-VM -ComputerName ServerName| Get-VMSnapshot | Remove-VMSnapshot”

You can see that Microsoft has built out both administrator and end user access to health care. I’m excited to see what the community does with tools like hv_blitz, as there are tons of opportunities for improvement. For instance, here are some of the challenges I’ll offer:

  • Grouped output around host, then virtual machine, with all important metrics
  • Virtual Machine integration components version
  • Virtual Machine backup status from DPM

I am an ardent supporter of Orchestrator, but you’ll find that oftentimes you’ll need to perform a task that Orchestrator doesn’t have an activity for. That said, even if an integration activity doesn’t exist, we can typically utilize PowerShell within an Orchestrator activity.

I hope this helps out some who are interested in starting to play with Hyper-V and its scripting capabilities. If there are questions please let me know and I’ll do my best to answer them.

Comments (3)
  1. tonyr says:

    to add to this you could query ad based on this ldap filter an input this to the above script


  2. Nathan Lasnoski says:

    Thanks!  Great idea.

  3. Nathan Lasnoski says:

    Very cool idea Tony!

Comments are closed.

Skip to main content