- Community Home
- >
- Servers and Operating Systems
- >
- HPE ProLiant
- >
- Server Management - Remote Server Management
- >
- Re: iLO Powershell Write-Host Error Message
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-26-2016 12:54 PM
тАО05-26-2016 12:54 PM
iLO Powershell Write-Host Error Message
I'm running the HP iLO cmdlets on a Task Schedule on Windows 2012 R2 Server. The script works great except I am tyring to find a way the Get-HPiLOHealthSummary cmdlet to output certain errors. Currently it only sends this part of the error: "System.Management.Automation.RuntimeException: You cannot call a method on a null-valued expression", if it detects that a server is offline.
What im looking to accomplish, is to only send me the iP Address Error info that outputs on the first line on the cmdlet via the email Body. It looks something like this: "Error - 10.10.5.2 - - retrieving information from iLO". That way if a server is offline (over 40 Servers in the array), I can quickly determine which server is offline with the IP address.
It looks like the HP iLO cmdlet is possibly using a Write-Host to output their error message and that may be the issue. Can somoene please assist.
Get-Content C:\iLO.txt | ForEach-Object { $all = Get-HPiLOHealthSummary -Server $_ -Username User -Password Pass -DisableCertificateAuthentication foreach ($status in $all) { New-Object psobject -Property @{ Fans = $status.Fans.STATUS PSupply = $status.POWER_SUPPLIES.STATUS Temperature = $status.TEMPERATURE_STATUS Status = $status.STATUS_TYPE Drives = $status.STORAGE_STATUS BIOS = $status.BIOS_HARDWARE_STATUS Memory = $status.MEMORY_STATUS Network = $status.NETWORK_STATUS CPU = $status.PROCESSOR_STATUS IP = $status.IP Hostname = $status.HOSTNAME } | Select-Object Hostname,IP,Fans,PSupply,Temperature,Status,Drives,BIOS,Memory,Network,CPU | Export-Csv -Path C:\Scripts\ilo\ilo.csv -Append -NoTypeInformation }} $body = $Error[1]|ConvertTo-Html |Out-String $mailprops=@{ Subject = 'ilo Status' Attachments = 'C:\ilo.csv' SmtpServer = 'MyServer' From = 'Ilo@hpilo' To='OurAdmins.com' BodyAsHtml=$true } Send-MailMessage @mailprops -Body $body
- Tags:
- iLO
- powershell
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-31-2016 01:45 PM
тАО05-31-2016 01:45 PM
Re: iLO Powershell Write-Host Error Message
Not 100% sure I'm actually addressing your question, but you could maybe try using ErrorVariable, like this:
$all = Get-HPiLOHealthSummary -Server $_ -Username User -Password Pass -DisableCertificateAuthentication -ErrorAction SilentlyContinue -ErrorVariable iloErr
Then check to see if $iloErr is not $null, and check its contents.
I just ran into what appears to be a bug w/ the current version of the HP iLO cmdlets when using 'DisableCertificateAuthentication' that might result in spurious error messages in your error variable, however. This is actually how I found your thread (some of the error text is similar). So if you run into that, this was the issue at around line 4548 in HPiLOCmdlets.psm1. Had to wrap their try block in an if statement that tested for $null.
elseif($tempArrayForProcess[$i].parameterName -eq "Credential") { $credential_index = $i # Changed this block to work around bug that possibly occurs # when "DisableCertificateAuthentication" is set. if (($tempArrayForProcess[$i] -ne $null) -and ($tempArrayForProcess[$i].parameterValue -ne $null)) { try{ # Getting a "cannot call a method on a null-valued expression" on this line if # we don't check for $null in the if statement above $typeCredential = $tempArrayForProcess[$i].parameterValue.GetType().Name } catch { $typeCredential = $null $global:error.RemoveAt($global:error.count-1) } } }
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-23-2016 12:54 PM
тАО06-23-2016 12:54 PM
Re: iLO Powershell Write-Host Error Message
Thank you for the reply. I was able to solve this issue by using this solution by Dave Wyatt.
https://powershell.org/forums/topic/hp-ilo-cmdlets-violate-the-first-law-of-powershell/