-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvSphere Buddy HDD.ps1
More file actions
63 lines (38 loc) · 1.14 KB
/
vSphere Buddy HDD.ps1
File metadata and controls
63 lines (38 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#Get the script location
$scriptPath = split-path -parent $MyInvocation.MyCommand.Definition
#return content of a file
function Get-ObjectList
{
param($key,$path)
if($key -eq "computer")
{
$content = Get-Content $path\computers.txt|Where-Object{$_.trim() -ne ''}|foreach{$_.trim()}
}
elseif($key -eq "vm"){$content = Import-Csv $path\vms.csv}
return $content
}
function Get-VMDisks
{
param($vm)
Get-VM $vm| Get-HardDisk |
Select @{N='VM';E={$_.Parent.Name}},
capacityGB,Filename,
@{N='SCSIid';E={
$hd = $_
$ctrl = $hd.Parent.Extensiondata.Config.Hardware.Device | where{$_.Key -eq $hd.ExtensionData.ControllerKey}
"$($ctrl.BusNumber):$($_.ExtensionData.UnitNumber)"
}},
@{N='Type';E={
$type = Get-ScsiController -HardDisk $_|Select-Object Type
"$($type.Type)"
}}
}
cls
foreach($vm in (Get-ObjectList computer $scriptPath))
{
Write-Host "Fetching $vm HDD info"
$obj += Get-VMDisks $vm
}
cls
$obj |ft
Read-Host "Press Enter to go back"