Hyper-V Reporting Script (Powershell & HTML)

It can be difficult to monitor and assess resources in large Hyper-V environments. This Powershell based script helps you to understand virtualization inventory, capacity and general resource availability in your Standalone or Clustered Hyper-V Environment.

 
 
 
 
 
4.9 Star
(96)
31,075 times
Add to favorites
Servers
3/5/2015
E-mail Twitter del.icio.us Digg Facebook
  • HTML output messed up with latest Chrome and FF
    8 Posts | Last post January 14, 2020
    • Hello,
      
      First of all, thank you for this awesome script. 
      
      I have had it running as a task every morning and just noticed (granted can't recall last time I checked the outputs) that the HTML output is all screwed up in the latest versions of Chrome 65.0.3325.146 and Firefox 58.0.2. Internet Explorer Version: 11.251.16299.0 Update Versions: 11.0.51 (KB4074736) is fine.
      
      Each VM is supposed to be on a new line but they end up like so: where the Disk Column should be the last column, now the VM that is supposed to be on the second line starts below and beside where the Disk Column is, the third VM starts, again, below and beside where the Disk column cell of VM two is and this creates a staircase-like horizontal view vs a nice vertical view. 
      
      Is this a browser issue in interpreting the HTML table or is it an issue with the table itself?
    • Same issue here.  
    • Well, I could not find a way to fix this but I consulted a buddy of mine that does HTML work all day long. He looked at it and a moment later said that it has to do with how Chrome and FF interpret (or, rather, don't interpret) zero rowspan (rowspan="0"). So, as both of us had no desire to go through 3k+ lines of code he suggested adding the below script to the beginning of #region HTML End, after line 3398 between the <br> and </body>
      
      <script>
      var els = document.querySelectorAll('td');
      for (var i=0; i < els.length; i++) {
          els[i].setAttribute('rowspan', 1);
      } 
      </script>
      
      
      And we are good to go :)
    • Well, not quite, this needs more work. It does fix some but not all the issues. Sorry, I jumped the gun as everything worked fine on 4 of my HPVs but if you have a VM with multiple disks then it puts the second vhd on a separate line, on its own. Still, it looks much better than the staircase view. If I find the answer I'll let you know.
    • This code solved it for us. Same guy, but spent a bit longer :)
      
      <script>
      var els = document.querySelectorAll('td');
      for (var i=0; i < els.length; i++) {
      	if(els[i].getAttribute('rowspan') === '0'){
      		els[i].setAttribute('rowspan', 1);
      	}
      }
      </script> 
      
      Now everything works as expected!!!
    • in what place You put this code ?
    • After line 3398, search for #region HTML End
      Pop it in between
      <br>
      Right here
      </body>
      
      
      Thanks for putting time into this @Yonkoc
    • Hi Team , 
      
      i love the script and it makes life so easy , i am new to scripting just want to know , if the output of the script can be captured in CSV format , Please Help
  • Not Worked in one specific hyper-v 2016 cluster
    1 Posts | Last post December 11, 2019
    • I'm receiving the following error in all VMs when running this script:
      
      Get-VHD : Cannot validate argument on parameter 'Path'. The argument is null or empty. Provide an argument that is not null or empty, and then try the 
      command again.
      At C:\hvreport\Get-HyperVReport.ps1:2245 char:83
      + ...     $vmDiffDisk = Get-VHD -ComputerName $VMHostItem -Path $parentPath
      +                                                               ~~~~~~~~~~~
          + CategoryInfo          : InvalidData: (:) [Get-VHD], ParameterBindingValidationException
          + FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.Vhd.PowerShell.Cmdlets.GetVHD
  • Update Hyper-V Server Cluster 2016
    1 Posts | Last post April 05, 2019
    • The best script ever.
      
      Sad that not received updates more.
      
      I really need this for Server 2016.
      
  • Running from remote machine
    1 Posts | Last post April 05, 2019
    • I am running the script from a remote machine that has Hyper-V powershell enabled. When it starts gathering Hyper-V Host info this is what I see:
        Get-VMHost : Hyper-V Management Tools could not access an expected WMI class on computer "remotecomputer" at C:\users\userid\documents\Get-HyperVReport.ps1:1357 char:17
      
      What modifications do I need to make to the script so it does not do this?
      
  • I fixed "InvalidData: (:) [Get-VHD]" for Server 2016
    2 Posts | Last post March 09, 2019
    • I fixed this problem for Server 2016:
      
      At C:\adminscripts\get-hypervreport.ps1:2248 char:83
      + ...     $vmDiffDisk = Get-VHD -ComputerName $VMHostItem -Path $parentPath
      +                                                               ~~~~~~~~~~~
          + CategoryInfo          : InvalidData: (:) [Get-VHD], ParameterBindingValidationException
          + FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.Vhd.PowerShell.Cmdlets.GetVHD
      
      
      Will Serhat please respond? I don't want to post the fix "just like that" without consent.
      
      regards,
      
      Joachim Otahal
    • just give it to us please!? :D
  • HELPPPP!!!! Shared VHD!!!!!!!!!!!!!!!!!!
    1 Posts | Last post December 27, 2018
    • Hello,
      
      I think that your script don't care about shared VHD.
      
      
      On my cluster I've 4 Vm that shared 10 VHD (This VHD can growth to 2.5 Tb). The dashboard report that the CSV here are the shared VHD can get over 10 TB. Sou I think that the script accumulate the information to this shared VHD 4 times.
      
      Can you check please?
  • Adding a feature
    4 Posts | Last post October 04, 2018
    • I have a question or request, but before that, this script ROCKS!!  I had a nice one that I build as well, but this has way more detail...excellent work.  I modified yours to automatically email this to my team weekly, and have it set to email as an HTML instead of attaching the HTML file.  Looks great.
      
      Anyway, I was wondering how hard it would be to have the disks sizes listed as a column for the Virtual Machines.  What I mean is this, in your report, It inventories the VMs and lists checkpoints (Yes/ NO) and then will list all the disks, and checkpoints with size for each.  I would like a column that takes the sizes of all that and gives me a SUM total size for the actual spaced used.
      
      The reason is so that if a VM is allocated 120GB disk and used is 90GB, but the VM has 4 Checkpoints all at 90GB, then the actual storage consumed is 450GB.  This is a major blind spot for most storage admins and could cause VM corruption as well.
      
      Is there a Way to do this?
    • hey robert, could you tell me how you modified the script that it sends the report directly as html, i have also tried it but without luck...
    • Hi, Robert, could you tell me too, how did you modified the script that sends the report directly as html in body in e-mail.
      Thanks !
    • Hi Guys,
      
      I am no expert on powershell but I managed to get the HTML into the body of the email by adding the below into the script.
      
      
          $BodyReport = Get-Content "$ReportFile" -Raw
          Send-MailMessage	            -To		"youremail@address.com" `
      		 	            -Subject 	"Hyper-V Environment Report" `
      			            -From 		"HyperV_Report@mwuk.com" `
                                          -Attachments 		"$ReportFile" `
      			            -SmtpServer 	"smtp.address.com" `
      			            -BodyAsHtml	-Body $BodyReport
      
      
      I kept the attachment included as it displays better in IE but you can remove that by deleting the -Attachments line.
      
      You do not need to run the script with the -sendemail prem as it will be hard coded into the script now.
      
      Cheers
      
      Lance
      
  • HPV 2016?
    1 Posts | Last post September 10, 2018
    • Howdy,
      
      I made the change sabout the OS Detection but now I get spammed with the error below.  Anyone know an easy way to fix this?
      
      
      Get-VHD : Cannot validate argument on parameter 'Path'. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again.
      At C:\adminscripts\get-hypervreport.ps1:2248 char:83
      + ...     $vmDiffDisk = Get-VHD -ComputerName $VMHostItem -Path $parentPath
      +                                                               ~~~~~~~~~~~
          + CategoryInfo          : InvalidData: (:) [Get-VHD], ParameterBindingValidationException
          + FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.Vhd.PowerShell.Cmdlets.GetVHD
  • Can this be made compatible with windows 10 standalone host and Server 2016 hyperv standalone and cluster?
    1 Posts | Last post July 16, 2018
    • I havent tested it on the 2016 cluster as i am yet to build it but i would like it for  a windows 10 host so i can test on local.
  • You cannot call a method on a null-valued expression
    1 Posts | Last post June 15, 2018
    • great script!
      after several years using, a new deployment with 3 HV servers and the trid server shows, right after the Gathering Disk/Volume information...
      
      You cannot call a method on a null-valued expression.
      At C:\Users\administrator.EDUCA\Desktop\Get-HyperVReport.ps1:3144 char:17
      +                 $physicalDiskName = (($physicalDiskNameData | where{($_.Path).Pa ...
      + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
          + FullyQualifiedErrorId : InvokeMethodOnNull
      
      You cannot call a method on a null-valued expression.
      At C:\Users\administrator.EDUCA\Desktop\Get-HyperVReport.ps1:3161 char:17
      +                 $outPhysicalDiskName = $physicalDiskName.Replace("PHYSICALDRIVE" ...
      +                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
          + FullyQualifiedErrorId : InvokeMethodOnNull
      
      
      any ideas?
1 - 10 of 101 Items