• About me…
  • VMware
  • Powershell
  • DIY

ConfigMgr.nl

VMware, PowerShell, Automation, and more…

  • About me…
  • VMware
  • Powershell
  • DIY

Powershell – looking up HP warranty information

8 mei 2017 Powershell Script No Comments

Today I wanted to get an overview of the warranty information of our ESX hosts. All the hosts are added to a HP Insight Remote Support server so the warranty information is available. However, using this information from powershell is a bit more challenging.

Fortunately I found a powershell module named HPWarranty. Could this be the solution?

First, install the PowerShellGet module. Details about the installation can be found here. Personally, I installed the MSI installer.

Second, start a new Powershell session and type Install-Module -Name HPWarranty. You will get a warning to install the NuGet provider 2.8.5.201. Select Yes. The installation will pull some files from an untrusted repository so you will get a second warning about that. I selected Yes. The module is now installed.

To try it out I entered the following command:
Get-HPEntWarrantyEntitlement -ProductNumber 654081-B21 -SerialNumber CZ3434BB9K

For some reason it asked me for credentials but after escaping out I got this output:

So the next question might be: how can I retrieve the product number and serial number? For this I wrote a powershell function that utilizes anonymous access to iLO:

[code language=”powershell”]
Function Get-HPWarrantyInfo {

<# .SYNOPSIS Get HP warranty information from server .DESCRIPTION Use this script if you need to get warranty information .PARAMETER ComputerName Remote server name .EXAMPLE .\Get-HPWarrantyInfo.ps1 -ComputerName server1 Get the warranty information of the server server1 .NOTES Script name: Get-HPWarrantyInfo.ps1 Author: Jeroen Buren DateCreated: 08-05-2017 #>

[CmdletBinding(SupportsShouldProcess=$true)]

param(
[parameter(ValueFromPipeLine=$True,ValueFromPipeLineByPropertyName=$True)]
[string[]]$ComputerName = $env:COMPUTERNAME
)

Begin {
$ErrorActionPreference = ‘SilentlyContinue’
$ComputerCount = $ComputerName.Count
}

Process {
$outputobject = @()
Foreach ($Computer in $ComputerName) {
$ProgressCount++
Write-Progress -Activity "Getting warranty information…" -Id 1 -Status "$($ProgressCount) / $($ComputerCount)" -CurrentOperation "$Computer" -PercentComplete (($ProgressCount / $ComputerCount) * 100)
If (Test-Connection -ComputerName $Computer -Count 1 -Quiet) {
$XML = New-Object XML
#Retrieving iLO hardware information
$XML.Load("http://$Computer/xmldata?item=All")
If ($?) {
$object = New-Object PSObject -Property @{
Computername = $Computer
SerialNumber = $($XML.RIMP.HSI.SBSN)
ProductName = $($XML.RIMP.HSI.SPN)
SKU = $($XML.RIMP.HSI.PRODUCTID) -replace " ",""
WarrantyEndDate = $(Get-HPEntWarrantyEntitlement -ProductNumber $($XML.RIMP.HSI.PRODUCTID) -SerialNumber $($XML.RIMP.HSI.SBSN)).OverallEntitlementEndDate
}
$outputobject += $object
}
}
}
$outputobject.pstypenames.insert(0,’Hardware.Info’)
$outputobject | ft
}
}
[/code]

The script is inspired from this page.

Restoring Task Sequences the easy way

Powershell - looking up HP warranty information - part 2

Geef een reactie Antwoord annuleren

Deze website gebruikt Akismet om spam te verminderen. Bekijk hoe je reactie-gegevens worden verwerkt.

Meest recente berichten

  • Handy one-liners
  • The system has insufficient locker space for the image profile
  • Testing Script Runtime Service for vSphere – part 2
  • Reporting on your Windows Server backup
  • Testing Script Runtime Service for vSphere – part 1

Jeroen BurenFollow

Jeroen Buren
jeroen_burenJeroen Buren@jeroen_buren·
15 apr

Had some spare time... So I did the HCI Master Specialist Exam and nailed it ;-) #vExpert #VMware #HCI

Reply on Twitter 1382574365389258752Retweet on Twitter 1382574365389258752Like on Twitter 138257436538925875220Twitter 1382574365389258752
jeroen_burenJeroen Buren@jeroen_buren·
15 apr

Join VMware's global event on May 5th & 6th to see their strategy for the new distributed workforce. There will be 13 technical sessions on @WorkspaceONE and @vmwarehorizon, @VMwareSDWAN, @vmw_carbonblack, and more! https://www.vmware.com/anywhere-workspace-event.html?src=so_6075a9bbde44b&cid=7012H000001l6vL #AnywhereWorkspace

Reply on Twitter 1382569804020744192Retweet on Twitter 1382569804020744192Like on Twitter 13825698040207441922Twitter 1382569804020744192
jeroen_burenJeroen Buren@jeroen_buren·
10 apr

Go #XRP Go... To infinity and beyond!

Reply on Twitter 1380903963772469253Retweet on Twitter 1380903963772469253Like on Twitter 13809039637724692531Twitter 1380903963772469253
jeroen_burenJeroen Buren@jeroen_buren·
10 apr

En weer 3 minuten kou geleden...

Reply on Twitter 1380801147368304640Retweet on Twitter 1380801147368304640Like on Twitter 13808011473683046401Twitter 1380801147368304640
jeroen_burenJeroen Buren@jeroen_buren·
5 apr

Het wordt nu toch echt lente!! 😂 #SpringTime

Reply on Twitter 1379101934813114375Retweet on Twitter 1379101934813114375Like on Twitter 13791019348131143754Twitter 1379101934813114375
Load More...

Categorieën

Proudly powered by WordPress | Theme: Doo by ThemeVS.