VMware Slideshow

  1. $erroractionpreference = "SilentlyContinue" 
  2. $XL = New-Object -comobject Excel.Application 
  3. $TimeStamp = date 
  4. $XL.visible = $True 
  5. $WrkbkB = $XL.Workbooks.Add() 
  6. $WrkShtC = $WrkbkB.Worksheets.Item(1) 
  7. $WrkShtC.Cells.Item(1,1) = "DataCenter Name" 
  8. $WrkShtC.Cells.Item(1,2) = "Cluster Name" 
  9. $WrkShtC.Cells.Item(1,3) = "Virtual Machine Name" 
  10. $WrkShtC.Cells.Item(1,4) = "Status" 
  11. $WrkShtC.Cells.Item(1,5) = "IP Address" 
  12. $WrkShtC.Cells.Item(1,6) = "Operating System" 
  13. $WrkShtC.Cells.Item(1,7) = "Memory" 
  14. $WrkShtC.Cells.Item(1,8) = "Provisioned Disk Space" 
  15.  
  16. $d = $WrkShtC.UsedRange 
  17. $Global:Row =
  18. $DataCents = Get-DataCenter |select-object Name 
  19. foreach ($DataCent in $DataCents
  20.     $DataCent.name 
  21.     $DNme = $DataCent.name 
  22.     $WrkShtC.Cells.Item($Global:Row,1) = $DNme 
  23.  
  24.    ClustFunc 
  25.     
  26.  
  27. function global:ClustFunc () 
  28.     Get-DataCenter -name "$DNme" | Get-Cluster | select-object Name 
  29.     $Clusts = Get-DataCenter -name "$DNme" | Get-Cluster | select-object Name 
  30.     foreach ($Clust in $Clusts
  31.     
  32.         $CNme = $Clust.name 
  33.         VMFunc $CNme 
  34.         #$WrkShtC.Cells.Item(1,6) = $Global:Row 
  35.     
  36.      
  37. $Global:Row 
  38. function global:VMFunc () 
  39.     Get-Cluster -name "$CNme" | Get-VM 
  40.     $WrkShtC.Cells.Item($Global:Row,2) = $CNme 
  41.     $VirMachs = Get-Cluster -name "$CNme" | Get-VM | Select-object Name 
  42.     foreach($VirMach in $VirMachs
  43.     
  44.         $VMNme = $VirMach.name 
  45.         $WrkShtC.Cells.Item($Global:Row,3) = $VMNme 
  46.         $VMDet = Get-vm -name "$VMNme" 
  47.         $WrkShtC.Cells.Item($Global:Row,4) = $VMDet.PowerState 
  48.         $WrkShtC.Cells.Item($Global:Row,5) = $VMDet.guest.ipaddress 
  49.         $WrkShtC.Cells.Item($Global:Row,6) = $VMDet.guest.osfullname 
  50.         $WrkShtC.Cells.Item($Global:Row,7) = $VMDet.MemoryMB 
  51.         $WrkShtC.Cells.Item($Global:Row,8) = $VMDet.ProvisionedSpaceGB 
  52.         $Global:Row = $Global:Row + 1    
  53.      
  54.      
  55. $d.Interior.ColorIndex = 10 
  56. $d.Font.ColorIndex = 15 
  57. $d.Font.Bold = $True 
  58. $d.EntireColumn.AutoFit() 
  59. $WrkShtC.Cells.Item(3,10) = "Script Admin" 
  60. $WrkShtC.Cells.Item(3,10).Font.ColorIndex =
  61. $WrkShtC.Cells.Item(3,10).Font.Bold = $True 
  62. $WrkShtC.Cells.Item(3,10).EntireColumn.AutoFit() 
  63. $WrkShtC.Cells.Item(3,11) = "Phani Ghanta" 
  64. $WrkShtC.Cells.Item(3,11).Font.ColorIndex =
  65. $WrkShtC.Cells.Item(3,11).Font.Bold = $True 
  66. $WrkShtC.Cells.Item(3,11).EntireColumn.AutoFit() 
  67. $XL.DisplayAlerts = False 
  68. $WrkbkB.DisplayAlerts = False 
  69. $Pver = "" 
  70. $WrkbkB.SaveAs("F:\$($(get-date).tostring('yyyy-MM-dd'))_VirtualMachinesStatus.xls"
  71. $Xl.workbooks.close() 
  72. $XL.Quit() 
 
Loading...
Concentrated Tech NSoftware Dell Compellent Sponsored by Idera and Concentrated Tech and NSoftware and Dell Compellent
Copyright 2011 PowerShell.com. All rights reserved.