-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathGet-NAVolDetail.ps1
198 lines (166 loc) · 7.04 KB
/
Get-NAVolDetail.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
<#
.SYNOPSIS
Return detailed status report of NetApp volumes
.DESCRIPTION
Return detailed status report of NetApp volumes
This scipt/function was meant to expand the default output of Get-NaVol to include additional detail about NetApp volumes.
It also was meant to provide an easier means to gather vol details from multiple controllers and provide simplistic error handling.
NOTE: Any system running DataONTAP older than 8.2, will return "N/A" for some fields due lack of API support.
This script was developed against systems running 7-Mode.
When using "| Format-Table", note that by default only 10 properties will be returned, by default. You need to do: "| Format-Table -Property *" to get them all (see example)
.PARAMETER Controller
Name of NetApp Filer/Controller/s
.INPUTS
System.String
.OUTPUTS
System.Management.Automation.PSCustomObject
.EXAMPLE
.\Get-NAVolDetail.ps1 -Controller NETAPP01 -Verbose | Where-Object {$_.vFiler -ne 'vFiler0' | ogv
.EXAMPLE
.\Get-NAVolDetail.ps1 -Controller NETAPP01 -Verbose | Format-Table -AutoSize -Property *
.EXAMPLE
.\Get-NAVolDetail.ps1 -Controller NETAPP01,NETAPP02 -Verbose | Out-GridView
.EXAMPLE
.\Get-NAVolDetail.ps1 -Controller (Get-Content C:\NetAppFilerList.txt) -Verbose | Export-Csv C:\NetApp_Vol_Report.csv -NoTypeInformation
.EXAMPLE
.\Get-NAVolDetail.ps1 -Controller NETAPP01
## Output from ONTAP verions < 8.2 ##
Controller : NETAPP01
VolName : netapp01_nfs1
PercentUsed : 21%
TotalSize : 1.0 TB
Available : 812.4 GB
VolState : online
Dedupe : True
TotalFootPrint : N/A
VolDataFootPrint : N/A
VolGuaranteeFootPrint : N/A
FilesUsed : 370
FilesTotal : 32M
vFiler : vfiler0
Aggr : aggr1
AggrSize : N/A
## Output from ONTAP verions > 8.2 ##
Controller : NETAPP01
VolName : cifs_p_data
PercentUsed : 71%
TotalSize : 4.8 TB
Available : 1.4 TB
VolState : online
Dedupe : True
TotalFootPrint : 4 TB
VolDataFootPrint : 4 TB
VolGuaranteeFootPrint : 0
FilesUsed : 16M
FilesTotal : 32M
vFiler : cifsvf1
Aggr : aggr1
AggrSize : 22 TB
.NOTES
20141121 K. Kirkpatrick Created
#TAG:PUBLIC
GitHub: https://github.com/vScripter
Twitter: @vScripter
Email: [email protected]
[-------------------------------------DISCLAIMER-------------------------------------]
All script are provided as-is with no implicit
warranty or support. It's always considered a best practice
to test scripts in a DEV/TEST environment, before running them
in production. In other words, I will not be held accountable
if one of my scripts is responsible for an RGE (Resume Generating Event).
If you have questions or issues, please reach out/report them on
my GitHub page. Thanks for your support!
[-------------------------------------DISCLAIMER-------------------------------------]
#>
#Requires -Version 3
#Requires -Module DataONTAP
[cmdletbinding(PositionalBinding = $true)]
param (
[parameter(Mandatory = $true,
Position = 0)]
[alias('Filer')]
[string[]]$Controller
)
BEGIN {
Set-StrictMode -Version Latest
# define custom hash tables
$totalSize = @{ Label = 'TotalSize'; Expression = { ConvertTo-FormattedNumber $_.SizeTotal DataSize "0.0" } }
$available = @{ Label = 'AvailableSpace'; Expression = { ConvertTo-FormattedNumber $_.SizeAvailable DataSize "0.0" } }
$used = @{ Label = 'PercentUsed'; Expression = { ConvertTo-FormattedNumber $_.PercentageUsed Percent } }
$filesUsed = @{ Label = 'FilesUsed'; Expression = { ConvertTo-FormattedNumber $_.FilesUsed } }
$filesTotal = @{ Label = 'FilesTotal'; Expression = { ConvertTo-FormattedNumber $_.FilesTotal } }
$totalFootprint = @{ Label = 'TotalFootPrint'; Expression = { ConvertTo-FormattedNumber $_.TotalFootprint DataSize } }
$volumeDataFootPrint = @{ Label = 'VolDataFootPrint'; Expression = { ConvertTo-FormattedNumber $_.VolumeDataFootprint DataSize } }
$flexVolMetaDataFootPrint = @{ Label = 'FlexvolMetadataFootprint'; Expression = { ConvertTo-FormattedNumber $_.FlexvolMetadataFootprint DataSize } }
$aggregateSize = @{ Label = 'AggregateSize'; Expression = { ConvertTo-FormattedNumber $_.AggregateSize DataSize } }
} # BEGIN
PROCESS {
foreach ($system in $Controller) {
Write-Verbose -Message "Working on $($system.toupper())"
# set/clear variables on each interation
$volQuery = $null
$versionQuery = $null
$ontapSupported = $null
$connectController = $null
if (Test-Connection -ComputerName $system -Count 2 -Quiet) {
try {
# query for the volume details
$volQuery = Get-NAVol -Controller (Connect-NaController $system) -ErrorAction 'Stop' |
Select-Object OwningVfiler, Name, State, $totalSize, $used, $available, Dedupe, $filesUsed, $filesTotal, ContainingAggregate
# Grab the version of Data ONTAP; versions older than 8.2 do not support the 'volume-footprint-list-info-iter-start' API; assign a boolean value for later use
if ($(Get-NaSystemVersion -Controller (Connect-NaController $system)) -like '*8.2*') {
$ontapSupported = $true
} else {
$ontapSupported = $false
} # if/else
# interate through each volume
foreach ($vol in $volQuery) {
$objVol = @()
# create custom obj to store data
$objVol = [PSCustomObject] @{
Controller = $(($global:CurrentNaController.name.toupper()))
VolName = $vol.Name
PercentUsed = $vol.PercentUsed
TotalSize = $vol.TotalSize
Available = $vol.AvailableSpace
VolState = $vol.State
Dedupe = $vol.Dedupe
TotalFootPrint = if ($ontapSupported) {
$(ConvertTo-FormattedNumber -Value $((Get-NaVolFootprint -Controller (Connect-NaController $system) -Name $($vol.name)).TotalFootPrint) -Type DataSize)
} else {
"N/A"
}
VolDataFootPrint = if ($ontapSupported) {
$(ConvertTo-FormattedNumber -Value $((Get-NaVolFootprint -Controller (Connect-NaController $system) -Name $($vol.name)).VolumeDataFootPrint) -Type DataSize)
} else {
"N/A"
}
VolGuaranteeFootPrint = if ($ontapSupported) {
$(ConvertTo-FormattedNumber -Value $((Get-NaVolFootprint -Controller (Connect-NaController $system) -Name $($vol.name)).VolumeGuaranteeFootPrint) -Type DataSize)
} else {
"N/A"
}
FilesUsed = $vol.FilesUsed
FilesTotal = $vol.FilesTotal
vFiler = $vol.OwningvFiler
Aggr = $vol.ContainingAggregate
AggrSize = if ($ontapSupported) {
$(ConvertTo-FormattedNumber -Value $((Get-NaVolFootprint -Controller (Connect-NaController $system) -Name $($vol.name)).AggregateSize) -Type DataSize)
} else {
"N/A"
}
} # $objVol
# call obj
$objVol
} # foreach
} catch {
Write-Warning -Message "$system - $_"
} # try/catch
} else {
Write-Warning -Message "$system - Unreachable"
} # if/else
} # foreach
} # PROCESS
END {
Write-Verbose -Message "Done"
} # END