Posted in
Virtual Machine Manager,
Windows Powershell |
No Comment | 4,550 views | 16/07/2013 09:21
You can get CSV reports from your all Clusters with following PowerShell script:
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
| $Clusters = Get-Content -Path C:\Clusters.txt
foreach ($Cluster in $Clusters)
{
# Get CSV Disks
$CSVDisks = Get-ClusterSharedVolume -Cluster $Cluster
foreach ($CSVDisk in $CSVDisks)
{
# Get CSV Volume Information
$CSVVolumeInfo = $CSVDisk | Select -Expand SharedVolumeInfo
$CSVFriendlyName = $CSVVolumeInfo.FriendlyVolumeName
$CSVVolume = $CSVFriendlyName.Split("\")[2]
$CSVVolume = $CSVVolume.ToLower()
$CSVVolumeID = $CSVDisk.Id
$CSVState = $CSVDisk.State
# CSV Free Disk Space
[int]$CSVDiskDriveFreeSpace = ([math]::round((($CSVVolumeInfo | Select -Expand Partition).FreeSpace / 1GB), 0))
# CSV Total Disk Space
[int]$CSVDiskSpace = ([math]::round((($CSVVolumeInfo | Select -Expand Partition).Size / 1GB), 0))
# CSV Used Disk Space
[int]$CSVDiskDriveUsedSpace = [int]$CSVDiskSpace - [int]$CSVDiskDriveFreeSpace
# CSV Health
if ($CSVState -eq "Online")
{
if ($CSVVolumeInfo.MaintenanceMode -eq $False)
{
if ($CSVVolumeInfo.RedirectedAccess -eq $True)
{
$CSVHealth = "Warning"
$CSVHealthDetails = "Volume is in redirected access."
}
else
{
$CSVHealth = "Healthy"
$CSVHealthDetails = "Volume is healthy."
}
}
else
{
$CSVHealth = "Monitor"
$CSVHealthDetails = "Volume is in maintenance mode."
}
}
else
{
$CSVHealth = "Critical"
$CSVHealthDetails = "Volume is in offline state."
}
# CSV Reports
Write-Host $Cluster
$Value = $Cluster + ";" + $CSVVolume + ";" + $CSVDiskSpace + ";" + $CSVDiskDriveUsedSpace + ";" + $CSVDiskDriveFreeSpace + ";" + $CSVHealth
Add-Content -Value $Value -Path C:\CSVVolumes.txt
}
} |
$Clusters = Get-Content -Path C:\Clusters.txt
foreach ($Cluster in $Clusters)
{
# Get CSV Disks
$CSVDisks = Get-ClusterSharedVolume -Cluster $Cluster
foreach ($CSVDisk in $CSVDisks)
{
# Get CSV Volume Information
$CSVVolumeInfo = $CSVDisk | Select -Expand SharedVolumeInfo
$CSVFriendlyName = $CSVVolumeInfo.FriendlyVolumeName
$CSVVolume = $CSVFriendlyName.Split("\")[2]
$CSVVolume = $CSVVolume.ToLower()
$CSVVolumeID = $CSVDisk.Id
$CSVState = $CSVDisk.State
# CSV Free Disk Space
[int]$CSVDiskDriveFreeSpace = ([math]::round((($CSVVolumeInfo | Select -Expand Partition).FreeSpace / 1GB), 0))
# CSV Total Disk Space
[int]$CSVDiskSpace = ([math]::round((($CSVVolumeInfo | Select -Expand Partition).Size / 1GB), 0))
# CSV Used Disk Space
[int]$CSVDiskDriveUsedSpace = [int]$CSVDiskSpace - [int]$CSVDiskDriveFreeSpace
# CSV Health
if ($CSVState -eq "Online")
{
if ($CSVVolumeInfo.MaintenanceMode -eq $False)
{
if ($CSVVolumeInfo.RedirectedAccess -eq $True)
{
$CSVHealth = "Warning"
$CSVHealthDetails = "Volume is in redirected access."
}
else
{
$CSVHealth = "Healthy"
$CSVHealthDetails = "Volume is healthy."
}
}
else
{
$CSVHealth = "Monitor"
$CSVHealthDetails = "Volume is in maintenance mode."
}
}
else
{
$CSVHealth = "Critical"
$CSVHealthDetails = "Volume is in offline state."
}
# CSV Reports
Write-Host $Cluster
$Value = $Cluster + ";" + $CSVVolume + ";" + $CSVDiskSpace + ";" + $CSVDiskDriveUsedSpace + ";" + $CSVDiskDriveFreeSpace + ";" + $CSVHealth
Add-Content -Value $Value -Path C:\CSVVolumes.txt
}
}
You can export CSVVolumes.txt into Excel file for a good looking reporting :)