SHARE
TWEET

Untitled

a guest Jun 25th, 2019 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Get-VM –ComputerName $hostnm |
  2.     Select-Object Name, State, Uptime,
  3.         @{Name="RAM In GB";Expression={[Math]::Round($_.MemoryAssigned/1GB, 2)}} |
  4.     ConvertTo-Html -Head $a
  5.  
  6. Measure-VM –Name * -Computername $hostnm |
  7.     Sort-Object VMName |
  8.     Select-Object VMName,
  9.         @{Name="RAM In GB";Expression={[Math]::Round($_.MaxRAM/1024, 2)}},
  10.         @{Name="Disk Size in GB";Expression={[Math]::Round($_.TotalDisk/1024, 2)}} |
  11.     ConvertTo-Html -Head $a
  12.      
  13. $vmhost = Get-Content C:UsersShare1DesktopScriptsVMHosts.txt
  14. $file = "C:UsersShare1DesktopScriptsoutput.htm"
  15.  
  16. $report = "<html> <body>"
  17. $a = "<style>"
  18. $a = $a + "body {font-family: Tahoma; background-color:#fff;}"
  19. $a = $a + "table {font-family: Tahoma;width: $($rptWidth)px;font-size: 12px;border-collapse:collapse;}"
  20. $a = $a + "th {background-color: #cccc99;border: 1px solid #a7a9ac;border-bottom: none;}"
  21. $a = $a + "td {background-color: #ffffff;border: 1px solid #a7a9ac;padding: 2px 3px 2px 3px;vertical-align: middle;text-align:center;}"
  22. $a = $a + "</style>"
  23.  
  24. $op1 = @()
  25. $op2 = @()
  26. $myresult = @()
  27.  
  28. $output = foreach ($hostnm in $vmhost) {
  29.     Enable-VMResourceMetering -Name $hostnm -ResourcePoolType @("Processor","VHD","Ethernet","Memory")
  30.  
  31.     echo "--------------------</br>"
  32.     echo "<b>" $hostnm  "</b></br>"
  33.     echo "--------------------</br>"
  34.  
  35.     $op1 = Get-VM –ComputerName $hostnm |
  36.            Select-Object Name, State, Uptime,
  37.                @{Name="RAM In GB"; Expression={[Math]::Round($_.MemoryAssigned/1GB, 2)}} |
  38.            ConvertTo-Html -Head $a
  39.  
  40.     Get-VM –Name * -ComputerName $hostnm | Enable-VMResourceMetering
  41.     $op2 = Measure-VM –Name * -ComputerName $hostnm |
  42.            Sort-Object VMName |
  43.            Select-Object VMName,
  44.                @{Name="RAM In GB";Expression={[Math]::Round($_.MaxRAM/1024, 2)}},
  45.                @{Name="Disk Size in GB";Expression={[Math]::Round($_.TotalDisk/1024, 2)}} |
  46.            ConvertTo-Html -Head $a
  47.  
  48.     $myresult = $op1 + $op2
  49. }
  50.  
  51. $report = $report + $output + $myresult + "</body></html>"
  52. $report | Out-File $file
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top