Jump to content
DarrenDK

Computer Warranty Updater (HP/Dell/Lenovo)

Recommended Posts

Not sure if this affects the scripts:

 

Our records indicate your company is enrolled in our Dell EMC TechDirect APIs service.  You are requested to complete updates within tools using these APIs by December 15, 2019 to avoid interruptions in service.

 

What’s happening?

We are making security enhancements to the following TechDirect APIs: Warranty Management, Self-Dispatch and Technical Support Requests.  These changes require updates within your application environment. 

 

Where can I find details of the API changes?

Please log into your TechDirect account to view the updated technical specifications (SDK) documents for the APIs your organization uses. The required code changes are clearly highlighted. 

 

Having difficulty accessing your account? From TechDirect.com, click “Sign in”.  Then, select “Forgot password?” to receive an email with an active password link.

 

What actions do I need to take prior to December 15, 2019?

1.  Implement code changes per updated SDK documentation. We recommend getting started as soon as possible. 

2.  Retrieve your updated credentials available from August 19th on the TechDirect portal.

3.  Test your API updates using the sandbox API from August 19th onwards.

4.  Update your environment prior to December 15, 2019 to avoid interruptions for applications leveraging TechDirect APIs. 

We look forward to continuing to work with you in the TechDirect portal.  If you have any questions or need assistance, please email us at APIs_TechDirect@Dell.com.

 

Thank you,

Dell EMC TechDirect API Team

Share this post


Link to post
Share on other sites
On 7/10/2018 at 6:25 AM, DarrenDK said:
  • Open Immense Networks Scripts->Update-MissingWarranties, copy the value of the PowershellCode variable into Powershell ISE on the LabTech server and run it.
    1. There should be no errors about script execution or modules not found. You may get a rate limit error from the API, but that's relatively normal. 
  • Open your _System Automation->Onboarding->Initial System Configuration - Partner Script and insert a Script Run step that runs the Immense networks Scripts->Update-MissingWarranties script

Hi @DarrenDK,

Would you please let me know how i should run these two steps?

Thanks

Share this post


Link to post
Share on other sites

I just tried implementing this, and the Dell and Lenovo work out of the box!  However, I am getting an error with the HP one when I run it in PowerShell ISE.

Get-HPWarrantyInfo : Cannot bind argument to parameter 'AccessToken' because it is null.
At line:473 char:135
+ ... ret $HPAPISecret -SerialNumbers $LookupInfo -AccessToken $AccessToken
+                                                              ~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Get-HPWarrantyInfo], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Get-HPWarrantyInfo

Am I missing a step?  Or did something break or a Syntax change with the HP API?

Thanks!

Share this post


Link to post
Share on other sites

Yeah, still getting the error, but after doing some additional research, it does look like the HP API is currently broken, and has been since May of 2019.  All the HP warranty tools are having the same issue.

Thanks for everything, this is a very nice Labtech script!

Share this post


Link to post
Share on other sites

Amazing work! @DarrenDK 

When running this script, I get warranty information, which doesn't coincide with the information, when making a lookup at Lenovo - or at least, there some warranty missing.

For example, when looking up my own computer with serial PC0A51B2, I get the following information from the script:

Purchase date (dd/mm/yyyy): 18/02/2016
Expiration date: (dd/mm/yyyy): 03/04/2017

However when looking up the computer at Lenovo, it says:

image.png.a6a7837aa9bcc411a81d16c9c127adbe.png

As you can see, if there is extended warranty purchased for the product, it's missing in the data received from the script... the script seems only to be able to extract the factory warranty. We have other computers, which have 3 years factory warranty, but have 2 years additional warranty purchased. This 'extended' warranty is not received from the script... 

Can something be done about this, or is this 'just' a limitation? What data do you receive from the REST API request?

Thanks again.

Share this post


Link to post
Share on other sites

So has anybody worked out an alternative for the HP API? Is there even one? I've reached out to our account manager today but can't see that being any help.

 

 

Share this post


Link to post
Share on other sites

I seem to have fixed it, by some trial and error. 

Made some modifications to the powershell script, so it catches both extended warranties AND non-extended (purchased-extended) warranties now. 
This is only for Lenovo computers.

Thanks again, @DarrenDK for this. 

Share this post


Link to post
Share on other sites
13 minutes ago, Anders Bermann said:

I seem to have fixed it, by some trial and error. 

Made some modifications to the powershell script, so it catches both extended warranties AND non-extended (purchased-extended) warranties now. 
This is only for Lenovo computers.

Thanks again, @DarrenDK for this. 

If you post your changes, I'm happy to update the original

 

Did your changes happen to fix the HP stuff or just the Lenovo extended warranty situation?

Share this post


Link to post
Share on other sites
1 hour ago, DarrenDK said:

If you post your changes, I'm happy to update the original

 

Did your changes happen to fix the HP stuff or just the Lenovo extended warranty situation?

This is only for Lenovo.

Within the webresponse variable, there's a value which is being queried, which makes up the warranty end-date. 

Basically I query two variables instead of one. After exporting the webresponse as XML, I analyzed it, and found that there are two variable (depending on whether there's extended warranty or not) being filled. 

The first one is: 

$webresponse.wiOutputForm.warrantyInfo.serviceInfo.wed | select -first 1

That one, is the factory warranty. But after looking at the XML file, I found that there's another one too. That one is found by querying a bit different:

$webresponse.SelectSingleNode("//mEndDate") | Select-Object -ExpandProperty `#text

After finding this, I realised, that the mEndDate is only set, if extended warranty is present. So I made a simple if-else statement, to check for $null value:

        $WarrantyEndDate_Expanded = $webresponse.SelectSingleNode("//mEndDate") | Select-Object -ExpandProperty `#text

        if ($WarrantyEndDate_Expanded -eq $null) {

            $WarrantyEndDate_Expanded = $webresponse.wiOutputForm.warrantyInfo.serviceInfo.wed | select -first 1

        }

I have uploaded a text file for the updated Function: Get-LenovoWarrantyInfo. 
When updating the original script, just replace the function with the modified one :)

The only changed made, is written above. 

Thanks again for your work.

Updated_Get-LenovoWarrantyInfo.txt

  • Like 1

Share this post


Link to post
Share on other sites
Posted (edited)
Hey everyone.

We, too, have been struggling due to the HP API issues.

I finally got tired enough of WarrantyMaster to track down some info today....
#Install the HPWarranty Module:
Install-Module -Name HPWarranty

#Check Warranty of a Workstation (HPInc = Workstations)
(Get-HPIncWarrantyEntitlement -SerialNumber $SerialNumber -ProductNumber $ProdNumber)

#Check Warranty of a Server (HPEnt = Servers)
(Get-HPEntWarrantyEntitlement -SerialNumber $SerialNumber -ProductNumber $ProdNumber)
If you install the HPWarranty module and use the GET-HPIncWarrantyEntitlement line, it will return the warranty information - I hope this might be helpful in fixing the HP issues with the warranty checker script.
 
The product number can be pulled from the "Chassis SKU Number" field in Automate.
 
I don't know if there is a limit to how many requests within a specified time period that HP may enforce on this.....
 
Link to the github for the Module: https://github.com/dotps1/HPWarranty
Edited by scubes13

Share this post


Link to post
Share on other sites
Posted (edited)

Hi scubes13 & MidbossQ,

I’m Adrian Macartney, Product Manager at Warranty Master. 

My team shared your post with me and I'd like to help out.

Sorry to hear that you haven’t had the best experience with Warranty Master. We're always working to ensure our Partners have the best experience possible. I’d personally like to understand the challenges you’re experiencing. I invite you to email me directly adrian@warrantymaster.com to discuss further.

Thanks,

Adrian

Edited by Warranty_Master

Share this post


Link to post
Share on other sites

@scubes13 @MidbossQ

Quick and dirty using the HPWarranty powershell module. In my debugging I found that the start and end dates were coming back as arrays (some times as many as 3 dates each), but the first entry seems the be the active warranty/care pack entitlement. Ran successfully against a couple hundred workstations in our db.

Function Update-MissingHPWarranties-PSModule
{   

    $HPComputers = Get-LabtechData -query "select ComputerID, BiosVer sn, (case WarrantyEnd when '0000-00-00 00:00:00' then '1979-01-01' else WarrantyEnd end) as 'WarrantyEnd', inv_chassis.SKUNumber pn from computers join inv_chassis using(computerid) where BiosMFG like 'h%p%' and (WarrantyEnd='0000-00-00 00:00:00' or assetdate > WarrantyEnd)"
    "$($HPComputers.Count) HP computers found in need of warranty information"  
    
    
    for($i=0;$i -lt $HPComputers.Count;$i++)
        {
            $WarrantyInfo = Get-HPIncWarrantyEntitlement -SerialNumber $HPComputers[$i].sn -ProductNumber $HPComputers[$i].pn
                        
            if($WarrantyInfo.OverallEntitlementStartDate -ne $null)
                {
                    try
                    {
                        if(($WarrantyInfo.OverallEntitlementEndDate | Measure-Object).Count -gt 1)
                            {
                                $end = $([DateTime]::Parse($WarrantyInfo.OverallEntitlementEndDate[0]))
                            }else{
                                $end = $([DateTime]::Parse($WarrantyInfo.OverallEntitlementEndDate))
                            }

                        if(($WarrantyInfo.OverallEntitlementStartDate | Measure-Object).Count -gt 1)
                            {
                                $start = $([DateTime]::Parse($WarrantyInfo.OverallEntitlementStartDate[0]))
                            }else{
                                $start = $([DateTime]::Parse($WarrantyInfo.OverallEntitlementStartDate))
                            }


                        Update-WarrantyInLabTech -ComputerID $HPComputers[$i].ComputerID -ShipDate $start -WarrantyEndDate $end -ErrorAction Stop
                    }
                    catch
                    {
                        Write-Output "Error updating $($HPComputers[$i].ComputerID): End date: $end"
                    }
                }
                else
                {
                    Write-Output "No Warranty Info returned for $($HPComputers[$i].ComputerID)"
                }
        }
        
        
     
}

 

Share this post


Link to post
Share on other sites

Updated functions for the new Dell v5 API. They switched to OAUTH2, so you have to request a new API key and get a client ID & secret from them. First is updated Get-DellWarrantyInfo, which is reworked with the new API and request format.

Function Get-DellWarrantyInfo
{
	Param(
	[Parameter(
	Mandatory = $true,
	ParameterSetName = '',
	ValueFromPipeline = $true)]
    [Array]$ServiceTags,
    [Parameter(
	Mandatory = $true,
	ParameterSetName = '',
	ValueFromPipeline = $true)]
    [Array]$AccessToken
	)
	
    $AuthHeader = @{Authorization="Bearer $AccessToken"}

    $JobResponse = Invoke-RestMethod -Method Get -Uri "https://apigtwb2c.us.dell.com/PROD/sbil/eapi/v5/asset-entitlements?servicetags=$ServiceTags" -headers $AuthHeader -ContentType 'application/json'

    $AllComputerWarranties = $JobResponse | ?{ $_.entitlements } | %{
           $ThisComputerApiResponse = $_
           $ShipDate = $ThisComputerApiResponse.shipDate
           $ThisComputerWarranties = $ThisComputerApiResponse.entitlements | ?{ $_.ServiceLevelCode -notlike "D" }
           $WarrantyStart = $ThisComputerWarranties | sort startDate | Select -First 1 -ExpandProperty startDate
           $WarrantyEnd = $ThisComputerWarranties | sort EndDate | Select -Last 1 -ExpandProperty endDate
           if(-not [String]::IsNullOrEmpty($ShipDate) -and -not [String]::IsNullOrEmpty($WarrantyEnd))
           {
            New-Object psobject -Property @{"WarrantyEndDate"=[DateTime]::Parse($WarrantyEnd.SubString(0,10));"ShipDate"=[DateTime]::Parse($ShipDate.SubString(0,10));"SerialNumber"=$_.ServiceTag}         
           }
           else
           {
            Write-Warning "Invalid Warranty Info received for ServiceTag: $($ThisComputerApiResponse.ServiceTag) ShipDate: $ShipDate WarrantyEnd: $WarrantyEnd `r`n$($ThisComputerWarranties)"
           }
        }

    $AllComputerWarranties
}

And the tweaked Update-MissingDellWarranties function, which now requires ClientID and ClientSecret instead of just an API key.

Function Update-MissingDellWarranties
{
	Param(
	[Parameter(
	Mandatory = $true,
	ParameterSetName = '',
	ValueFromPipeline = $true)]
	[string]$DellClientId,
    [Parameter(
	Mandatory = $true,
	ParameterSetName = '',
	ValueFromPipeline = $true)]
	[string]$DellClientSecret
	)

	$ComputersMissingWarranty = Get-LabtechData -Query "select ComputerID, BiosVer, (case WarrantyEnd when '0000-00-00 00:00:00' then '1979-01-01' else WarrantyEnd end) as 'WarrantyEnd' from computers where BiosMFG = 'Dell' and length(trim(BiosVer)) = 7 and (WarrantyEnd='0000-00-00 00:00:00' or assetdate > WarrantyEnd)"
	
    if($ComputersMissingWarranty.Count -eq 0)
    {
        "No Dell computers missing warranty"
        return
    }

    $uri = "https://apigtwb2c.us.dell.com/auth/oauth/v2/token"

    if(-not $AccessToken)
    { 
        $AuthResponse = Invoke-RestMethod -Method Post -Uri $uri -Body "client_id=$DellClientID&client_secret=$DellClientSecret&grant_type=client_credentials" -ContentType "application/x-www-form-urlencoded"
        if(-not $AuthResponse)
        {
            "Dell API timed out while obtaining access token. Plese try again later"
            return
        }
        $AccessToken = $AuthResponse | select -ExpandProperty access_token
    }

    Write-Host "AccessToken: $AccessToken"

    $Chunks = Split-Array -inArray $ComputersMissingWarranty -size 100

    foreach($Chunk in $Chunks){
        $WarrantyInfoArray = @()
        $WarrantyInfoArray += Get-DellWarrantyInfo -ServiceTags $($Chunk.BiosVer -join ',') -AccessToken $AccessToken
        $WarrantyInfoArray | %{
            $WarrantyInfo = $_
            $ComputerID = $ComputersMissingWarranty | ?{$_.biosver -like $WarrantyInfo.SerialNumber} | select -first 1 -ExpandProperty ComputerID
            Update-WarrantyInLabTech -ComputerID $ComputerID -ShipDate $WarrantyInfo.ShipDate -WarrantyEndDate $WarrantyInfo.WarrantyEndDate
        }
    }
}

 

Share this post


Link to post
Share on other sites

Hi DarrenDK

Very useful tool but need some assistance if possible please. I have completed steps as pointed out but getting the follow errors when running in Powershell ISE

Updating Dell Warranties
Invoke-RestMethod : The remote server returned an error: (401) Unauthorized.
At line:254 char:17
+     $Response = Invoke-RestMethod $Request.Uri -ContentType "application/json"
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebE 
   xception
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand
 
Invoke-RestMethod : The remote server returned an error: (401) Unauthorized.
At line:254 char:17
+     $Response = Invoke-RestMethod $Request.Uri -ContentType "application/json"
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebE 
   xception
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand

 

37 HP computers found in need of warranty information
select : Property "access_token" cannot be found.
At line:464 char:40
+         $AccessToken = $AuthResponse | select -ExpandProperty access_token
+                                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (apiKey=TyI6keB5...&scope=warranty:PSObject) [Select-Object], PSArgum 
   entException
    + FullyQualifiedErrorId : ExpandPropertyNotFound,Microsoft.PowerShell.Commands.SelectObjectCommand
 

 

Share this post


Link to post
Share on other sites
34 minutes ago, Rob Leverton said:

Hi DarrenDK

Very useful tool but need some assistance if possible please. I have completed steps as pointed out but getting the follow errors when running in Powershell ISE

Updating Dell Warranties
Invoke-RestMethod : The remote server returned an error: (401) Unauthorized.
At line:254 char:17
+     $Response = Invoke-RestMethod $Request.Uri -ContentType "application/json"
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebE 
   xception
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand
 
Invoke-RestMethod : The remote server returned an error: (401) Unauthorized.
At line:254 char:17
+     $Response = Invoke-RestMethod $Request.Uri -ContentType "application/json"
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebE 
   xception
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand

 

37 HP computers found in need of warranty information
select : Property "access_token" cannot be found.
At line:464 char:40
+         $AccessToken = $AuthResponse | select -ExpandProperty access_token
+                                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (apiKey=TyI6keB5...&scope=warranty:PSObject) [Select-Object], PSArgum 
   entException
    + FullyQualifiedErrorId : ExpandPropertyNotFound,Microsoft.PowerShell.Commands.SelectObjectCommand
 

 

Are you using the older original code? You may want to read the newest posts in this thread, Dell has changed their system and HP took theirs offline completely.

Share this post


Link to post
Share on other sites

Thanks @lgs141 @DarrenDK- maybe that the issue then yes. I understood the code in the original post had been updated up to and including March 28 2019 but possibly not.

Could you share the code that is more recent (in its entirety) so I don't miss anything?

Much appreciated!

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...