forked from nullzeroio/PowerShell
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Get-NAAggrDetail.ps1
110 lines (89 loc) · 2.89 KB
/
Get-NAAggrDetail.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
<#
.SYNOPSIS
Return detailed status report of NetApp Aggregates
.DESCRIPTION
Return detailed status report of NetApp Aggregates
This scipt/function was meant to expand the default output of Get-NaAggr to include additional detail about NetApp Aggregates.
It also was meant to provide an easier means to gather aggr details from multiple controllers and provide simplistic error handling.
This script was developed against systems running 7-Mode.
.PARAMETER Controller
Name of NetApp Filer/Controller/s
.INPUTS
System.String
.OUTPUTS
System.Management.Automation.PSCustomObject
.EXAMPLE
.\Get-NAAggrDetail.ps1 -Controller NETAPP01 -Verbose | Format-Table -AutoSize -Property *
.EXAMPLE
.\Get-NAAggrDetail.ps1 -Controller NETAPP01,NETAPP02 -Verbose | Out-GridView
.EXAMPLE
.\Get-NAAggrDetail.ps1 -Controller (Get-Content C:\NetAppFilerList.txt) -Verbose | Export-Csv C:\NetApp_Aggr_Report.csv -NoTypeInformation
.NOTES
20141121 K. Kirkpatrick Created
#TAG:PUBLIC
#>
#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 $_.SizePercentageUsed Percent } }
} # BEGIN
PROCESS
{
foreach ($system in $Controller)
{
Write-Verbose -Message "Working on $($system.toupper())"
# set/clear variables on each interation
$aggrQuery = $null
$versionQuery = $null
$ontapSupported = $null
$connectController = $null
if (Test-Connection -ComputerName $system -Count 2 -Quiet)
{
try
{
# query for the volume details
$aggrQuery = Get-NAAggr -Controller (Connect-NaController $system) -ErrorAction 'Stop' |
Select-Object Name, State, $totalSize, $used, $available, Disks, RaidType, MirrorStatus
# interate through each volume
foreach ($aggregate in $aggrQuery)
{
$objVol = @()
# create custom obj to store data
$objAggr = [PSCustomObject] @{
Controller = $(($global:CurrentNaController.name.toupper()))
AggrName = $aggregate.Name
PercentUsed = $aggregate.PercentUsed
TotalSize = $aggregate.TotalSize
Available = $aggregate.AvailableSpace
DiskCount = $aggregate.Disks
RaidType = $aggregate.RaidType
MirrorStatus = $aggregate.MirrorStatus
} # $objAggr
$objAggr
} # foreach
} catch
{
Write-Warning -Message "$system - $_"
} # try/catch
} else
{
Write-Warning -Message "$system - Unreachable"
} # if/else
} # foreach
} # PROCESS
END
{
Write-Verbose -Message "Done"
} # END