Use PowerShell to Determine the Uptime of an EqualLogic SAN
Recently, I received notification from EqualLogic support that there could be issues with their storage area networks running firmware version 7.0.x at 248 consecutive days of uninterrupted operation and they recommend updating to firmware version 7.0.9 to correct (and prevent) the problem.
While I know that I have EqualLogic storage area networks running in some of the data-centers I support, I'm not sure what version of firmware they're running or what the uptime on them is so I'll use PowerShell (of course) to determine this information.
The EqlPSTools PowerShell module is part of the EqualLogic HIT (Host Integration Tools) Kit for Microsoft which can be downloaded from the EqualLogic support site. Note that the support site states that customers must have an active service plan to gain access to it.
I decided to write a reusable function to perform the necessary tasks since the EqlPSTools module is in a DLL file that has to be manually imported and you would normally have to connect to each SAN, query it and them disconnect from it moving on to the next one.
I didn't want to have to figure all of that out each time I needed to determine this information so
I decided to write a function that would do all of that for me. I could even add it to a script
module that exists in my $env:PSModulePath
so it would automatically be available any time I
needed it without having to find and dot source a ps1 file.
1#Requires -Version 3.0
2function Get-MrEqlSANUptime {
3
4<#
5.SYNOPSIS
6 Gets the uptime for one or more EqualLogic storage area network members.
7
8.DESCRIPTION
9 Get-MrEqlSANUptime is a PowerShell function that retrieves the firmware
10 version, last boot time, and number of days of uptime from one or more
11 EqualLogic storage area network members. This function depends on the
12 EqlPSTools PowerShell module that is installed as part of the EqualLogic
13 HIT Kit.
14
15.PARAMETER GroupAddress
16 One or more IP Addresses of the EqualLogic storage area network(s) to
17 return the uptime information for.
18
19.PARAMETER ModulePath
20 Full path to the EqlPSTools.dll file that is installed as part of the
21 EqualLogic HIT Kit. This parameter defaults to the default location of
22 this DLL file.
23
24.PARAMETER Credential
25 Specifies a user account that has permission to perform this action. The
26 default is the current user.
27
28.EXAMPLE
29 Get-MrEqlSANUptime -GroupAddress 192.168.1.1 -Credential (Get-Credential)
30
31.EXAMPLE
32 Get-MrEqlSANUptime -GroupAddress 192.168.1.1 -ModulePath 'C:\Program Files\EqualLogic\bin\EqlPSTools.dll'
33
34.EXAMPLE
35 '192.168.1.1', '192.168.2.1' | Get-MrEqlSANUptime -Credential (Get-Credential)
36
37.INPUTS
38 String
39
40.OUTPUTS
41 PSCustomObject
42
43.NOTES
44 Author: Mike F Robbins
45 Website: http://mikefrobbins.com
46 Twitter: @mikefrobbins
47#>
48
49 [CmdletBinding()]
50 param (
51 [Parameter(Mandatory,
52 ValueFromPipeline)]
53 [string[]]$GroupAddress,
54
55 [ValidateNotNullOrEmpty()]
56 [string]$ModulePath = 'C:\Program Files\EqualLogic\bin\EqlPSTools.dll',
57
58 [System.Management.Automation.Credential()]$Credential = [System.Management.Automation.PSCredential]::Empty
59 )
60
61 BEGIN {
62 $problem = $false
63
64 $Params = @{
65 ErrorAction = 'Stop'
66 }
67
68 Write-Verbose -Message "Attempting to load EqlPSTools Module if it's not already loaded"
69 if (-not (Get-Module -Name EqlPSTools)) {
70 try {
71 Import-Module $ModulePath @Params
72 }
73 catch {
74 $problem = $true
75 Write-Warning -Message "An error has occured. Error details: $_.Exception.Message"
76 }
77 }
78
79 If ($PSBoundParameters['Credential']) {
80 $Params.credential = $Credential
81 }
82 }
83
84 PROCESS {
85 if (-not ($problem)) {
86 foreach ($Group in $GroupAddress) {
87 $Params.GroupAddress = $Group
88
89 try {
90 $Connect = Connect-EqlGroup @Params
91 Write-Verbose -Message "$Connect"
92 }
93 catch {
94 $Problem = $True
95 Write-Warning -Message "Please contact your system administrator. Reference error: $_.Exception.Message"
96 }
97
98 if (-not($Problem)) {
99 Get-EqlMember -GroupAddress $Group |
100 Select-Object -Property MemberName,
101 @{label='FirmwareVersion';expression={$_.FirmwareVersion -replace '^.*V'}},
102 @{label='BootTime';expression={(Get-Date).AddSeconds(-$_.Uptime)}},
103 @{label='UpTime(Days)';expression={'{0:N2}' -f ($_.UpTime / 86400) }}
104
105 $Disconnect = Disconnect-EqlGroup -GroupAddress $Group
106 Write-Verbose -Message "$Disconnect"
107 }
108
109 $Problem = $false
110 }
111 }
112 }
113}
The Get-EqlMember
cmdlet which is part of the EqlPSTools PowerShell module returns an uptime
property, but it's in total seconds and I'm not sure about you but a number like 12801888 doesn't
mean much to me without performing some additional calculations on it and I wanted the function to
do all of that for me (automate all things):
1Get-MrEqlSANUptime -GroupAddress 192.168.1.1, 192.168.2.1 -Credential (Get-Credential)
The Get-EqlMember
cmdlet only accepts a single IP address via parameter input and it can't be
provided via pipeline input so I would have had to query the SAN in each data-center manually, one
at a time or write some code to put them into a
ForEach-Object loop.
I wrote my reusable function so it would not only allow multiple IP addresses to be provided via parameter input, but also accept them via pipeline input in case I wanted to query the actual IP addresses from somewhere else like a text file or CSV and then provide that output as input for my function:
1$cred= Get-Credential
2'192.168.1.1', '192.168.2.1', '192.168.3.1' | Get-MrEqlSANUptime -Credential $cred
Based on the previous results, the reported issue isn't a crisis at the moment, but it's something that needs to be taken care of in less than 100 days and I can see there are a couple more that need to have their firmware updated that are on older versions.
The Get-EqlSANUptime
PowerShell function shown in this blog article can be downloaded from
my PowerShell Repository on GitHub.
µ