-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcheckdisk.ps1
69 lines (41 loc) · 1.7 KB
/
checkdisk.ps1
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
64
65
66
67
68
69
#Connect-VIServer vcenter.tamu.edu
$report = @()
#Sets path to where the report will be sent to...this will go to your desktop
$path = $HOME + '\desktop\VM_Disk_Detail.csv'
#gets all the VMs in the vCenter servers
$vmx = Get-VM | sort name
foreach
($vm in $vmx)
{
#Pull in the HDs associated with the VM
#If you just want to see Thin disks, REM line one, unREM line two
vmhds = $vm | Get-HardDisk
#vmhds = $vm | Get-HardDisk | where {$_.StorageFormat -eq 'Thin'}
foreach ($vmhd in $vmhds)
{
$diskStyle = $null
#Boolean field to see if disk is thin provisioned or not
thinPro = $vmhd.extensiondata.backing.thinprovisioned
#Indicates where the disk is thick or thin
$format = $vmhd.StorageFormat
#This will be null for thin disks and thick lazy-zero disks, should be true for thick eager-zero
eager = $vmhd.extensiondata.backing.Eagerlyscrub
#This will determine what the true format is. If it can't decide, disk type is unknown or 'UNK'
if ($eager -eq $null -and $format -eq 'Thick'){$diskStyle = 'ThickLazyZero'}
elseif ($eager -eq 'True' -and $format -eq 'Thick'){$diskStyle = 'ThickEagerZero'}
elseif ($format -eq 'Thin'){$diskStyle = 'ThinProv'}
else {$diskStyle = "UNK"}
$list = '' | select vmName,vmCluster,vmHDname,diskMode,eagerScrub,diskFormat,TP_TF,style,filename
$list.vmname = $vm.Name
$list.vmCluster = $vm.VMHost.Parent
$list.vmHDname = $vmhd.name
$list.diskMode = $vmhd.Persistence
$list.eagerScrub = $eager
$list.diskformat = $vmhd.StorageFormat
$list.TP_TF = $thinPro
$list.style = $diskStyle
$list.filename = $vmhd.filename
$report += $list
}
}
$report | Export-Csv -NoTypeInformation -Path $path