File tree Expand file tree Collapse file tree 2 files changed +36
-2
lines changed Expand file tree Collapse file tree 2 files changed +36
-2
lines changed Original file line number Diff line number Diff line change 3
3
4
4
#
5
5
# Paolo Frigo, https://www.scriptinglibrary.com
6
- # This script will sum all VM Footprints according to the filter PROD/TEST/DEV used.
7
- #
6
+ # This script will sum all VM Footprints according to your naming convention filter PROD/TEST/DEV used.
7
+ #
8
+ # VMNODES will list all hyper-v hosts
8
9
9
10
10
11
$Filter = " prod" # prod, test or dev
Original file line number Diff line number Diff line change
1
+ # requires -runasadministrator
2
+
3
+ #
4
+ # Paolo Frigo, https://www.scriptinglibrary.com
5
+ # This script will get the size of all VHDX files of all VMs hosted on your Hyper-V
6
+ #
7
+ # notes - Please have a look to get-vmfootprintbyenv.ps1 in case you want to run this
8
+ # script against multiple hyper-v hosts
9
+
10
+ function Get-VMFootprint ($VM ){
11
+ $total_size = 0
12
+ foreach ($disk in ($VM | Get-VMHardDiskDrive | Select-object - expandproperty path) ){
13
+ $total_size += Get-Item $disk | Select-Object - ExpandProperty Length
14
+ }
15
+ Return [math ]::round($total_size / 1 GB , 2 )
16
+ }
17
+
18
+ $couter = 0
19
+ $vm_counter = 0
20
+ $total = 0
21
+
22
+ foreach ($VMHost in $ALL_HSD_VM_NODES ){
23
+ $counter += 1
24
+ foreach ($VM in (get-vm - computername $VMHost )){
25
+ $vm_counter += 1
26
+ Write-Progress - Status " Get Footprint of $ ( $VM.Name ) " - Activity " Retrieve information from $ ( $VmHost ) " - PercentComplete $ ($couter / $NumNodes * 100 )
27
+ $VmSize = $ (Get-VMFootprint ($VM ))
28
+ Write-Verbose " $ ( $VM.Name ) - $VmSize GB"
29
+ $total += $VmSize
30
+ }
31
+ }
32
+
33
+ Write-Output " $vm_counter VMs Footprint: $total GB "
You can’t perform that action at this time.
0 commit comments