-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOA_iLO_Functions.ps1
100 lines (85 loc) · 3.08 KB
/
OA_iLO_Functions.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
<#
.SYNOPSIS
Functions for getting and updating iLO firmware.
.DESCRIPTION
Uses the HP OA Cmdlets to get and update iLO firmware. An image file (.bin) needs to be
provided via a URL, e.g. "http://<my server>/hp/ilo4_242.bin". Download the iLO firmware
update from HPE's website and extract the contents to find a file with the .bin extension.
.EXAMPLE
Get firmware versions less than 2.42.
Get-OAiLOFW -Chassis 10.0.0.1 | where 'Version' -lt '2.42'
.EXAMPLE
Get firmware versions from two chassis, passing the IPs in the pipeline, filter for the ones
less than 2.42 and update them:
"10.0.0.1","10.0.0.2" | Get-OAiLOFW | where 'Version' -lt '2.42' | Update-OAiLOFW
.LINK
https://www.hpe.com/servers/powershell
.LINK
https://github.com/doogleit/hpe-oneview-misc
#>
Function Get-OAiLOFW {
[cmdletbinding()]
param(
[Parameter(Mandatory=$True,Position=0,ValueFromPipeline=$true)]
[string]$Chassis,
[string]$Usr,
[string]$Pwd
)
begin {
$devices = @()
}
process {
# Connect to OA
$connection = Connect-HPOA -OA $Chassis -Username $Usr -Password $Pwd
# Get Chassis Firmware
$chassisFW = Get-HPOAFWSummary $connection
# Get Device Firmware
Write-Verbose "Getting firmware for devices in chassis $Chassis"
foreach ($device in $chassisFW.DeviceFirmwareInformation) {
foreach ($item in $device.DeviceFWDetail) {
if ($item.FirmwareComponent -match "iLO4") {
$deviceInfo = New-Object System.Object
$deviceInfo | Add-Member -Name Chassis -Value $Chassis -type NoteProperty
$deviceInfo | Add-Member -Name Bay -Value $device.Bay -type NoteProperty
$deviceInfo | Add-Member -Name Component -Value $item.FirmwareComponent -type NoteProperty
$deviceInfo | Add-Member -Name Version -Value $item.CurrentVersion -type NoteProperty
$devices += $deviceInfo
}
}
}
# Disconnect from OA
Disconnect-HPOA $connection
}
end {
return $devices
}
}
Function Update-OAiLOFW {
[cmdletbinding()]
param(
[Parameter(Mandatory=$True,Position=0,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true)]
[string]$Chassis,
[Parameter(Mandatory=$True,Position=1,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true)]
[string]$Bay,
[Parameter(Mandatory=$false,Position=2)]
[string]$FirmwareURL, # "http://<my server>/hp/ilo4_242.bin"
[string]$Usr,
[string]$Pwd
)
begin {
$results = @()
}
process {
# Connect to OA
$connection = Connect-HPOA -OA $Chassis -Username $Usr -Password $Pwd
# Update Device Firmware
Write-Verbose "Updating firmware on $Chassis bay #$Bay"
$results += Update-HPOAiLO -Connection $connection -Bay $Bay -url $FirmwareURL -Verbose
# Disconnect from OA
Disconnect-HPOA $connection
}
end {
return $results
}
}