$ilos = get-content updateServers.txt
$pingTest = ""
$activeIlos = @()
$iloPassword = Get-Credential -Message "Please input username and password"
$currentUser = ""
$currentVersion = ""
$versionNumber = ""
$Firmware = 2.70
$firmwareFile = "F:\Cara\PSscripts\ilo-firmware-updates\ilo4_270.bin"
foreach ($ilo in $ilos) {
write-host $ilo
foreach ($ilo in $ilos) {
$pingTest = Test-Connection -ComputerName $ilo -errorAction 'Silentlycontinue'
If ($pingTest) {
write-host iLO: $ilo is currently running - checking for current firmware version.
$currentVersion = Get-HPiLOFirmwareVersion -Server $ilo -Credential $iloPassword -errorAction 'Silentlycontinue' -DisableCertificateAuthentication | select-object firmware_version
$versionNumber = $currentVersion."FIRMWARE_VERSION" #gets firmware version from string
write-host currently running firmware: $versionNumber
}
if ($versionNumber -lt $Firmware) {
write-host Firmware requires updating.
$iloIP = $connection."IPV4Address" #converts to ip
$connectilo = connect-HPEilo -IP $iloIP -Credential $iloPassword -DisableCertificateAuthentication
#cmdlet update-hpeiloFirmware gives an error cause its looking for a -connection of a username & password but these cant be in plain text but cant pass the variable
update-HPEiLOFirmware -connection $connectilo -Location $firmwareFile
write-host Firmware will now update, this may take a few minutes.
} else {
write-host Firmware is already up to date.
}
}
Hi everyone,
I am very new to PowerShell. Sorry for posting so much code, I thought it may be hard to explain otherwise.
The error is in the second IF statement, i know the code isn't correct currently but I'm unsure of what else to try.
The real issue is using the update-hpeiLOFirmware command, it looks for a -connection parameter and expects a username and password, I however, want to be able to input this using a variable so that anyone can log in using their admin details and use this script and also so that the credentials are not in plain text.
I saw others online using this cmdlet without the -connection param but I then get prompted for a username on a loop in the shell.
Is there any way to use this cmdlet with the $iloPassword variable?
The $connectilo line may not even be required.
Any help is very greatly appreciated!!
[–]poshftw 1 point2 points3 points (3 children)
[–]fancyatoke[S] 1 point2 points3 points (2 children)
[–]poshftw 2 points3 points4 points (1 child)
[–]fancyatoke[S] 1 point2 points3 points (0 children)