Advertisement
Guest User

Untitled

a guest
Oct 13th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. $vcenterServerName = $env:vCenterServer
  2. $vcenterUserName = $env:vCenterServerUser
  3. $vcenterPassword = $env:vCenterServerPassword
  4.  
  5. $wildCardForSearch = "exch01"
  6. $baseFileName = $MyInvocation.MyCommand.Name
  7. $strCSVLocation = "c:\temp\"
  8.  
  9. Connect-VIServer $vcenterServerName -User $vcenterUserName -Password $vcenterPassword -ea silentlycontinue
  10. $vms = Get-VM | where-object {$_.Name -like $wildCardForSearch}
  11.  
  12. $stats = @()
  13.  
  14. foreach($vm in Get-VM){
  15. $info = Get-Datastore -RelatedObject $vm |
  16. Select @{N='Host';E={$vm.VMhost.Name}},
  17. @{N='VMName';E={$vm.Name}},
  18. Name,
  19. @{N='Capacity';E={[math]::Round($_.CapacityGB,1)}},
  20. @{N='Free';E={[math]::Round($_.FreeSpaceGB,1)}}
  21.  
  22. $stats += $info
  23. }
  24.  
  25. $fileSuffix = (get-date).toString('yyyyMMddhhmm')
  26. $fullReportPathWithFileName = $strCSVLocation + $baseFileName + "_" + $fileSuffix + ".csv"
  27. $stats | Export-Csv $fullReportPathWithFileName -NoTypeInformation -UseCulture
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement