Home Asset Management

Invoke the "Update Warranty" task from powershell

Eric_KrasnerEric_Krasner Customer Advanced IT Monkey ✭✭✭
I am creating an orchestrator runbook that will get all the Dell Warranty info for our computers, create a Warranty, and create the relationship with the HW Asset. However, the warranty does not update its status or days remaining until the task "Update Warranty" is run or the warranty is opened and saved.

I would like to run the update as part of my runbook.  So, I either need
1. A way to run the task from code, or
2. The code behind the task so I can use it.

Thanks

Best Answer

  • Eric_KrasnerEric_Krasner Customer Advanced IT Monkey ✭✭✭
    Answer ✓
    I would rather have the program calculate the Status and days left. 

    I am told that this update will happen nightly if I would just be patient.

Answers

  • Brett_MoffettBrett_Moffett Cireson PACE Super IT Monkey ✭✭✭✭✭
    Great question.

    I am not aware of any way to invoke this from code as I have PowerShell code that does exactly the same as what you are describing and I assume waiting for the Asset Refresh cycle to kick in.

    I'll be working on this same code over the coming weeks so if you would like to collaborate on this I'd be happy to see what we can achieve.

    Send me a direct message if you want to get this happening, and when finished, we can share with the community.

  • Ernest_FaccioliniErnest_Facciolini Customer IT Monkey ✭
    edited April 2017

    I am just wrapping up pulling in warranty data from dell as well. The ContractStatus and DaysLeft fields on the Warranty object can be set in Orchestrator, so I just do some date arithmetic to find the days left (or 0 if past) and then some additional logic to set the string value of Contract Status to Warning, Expired or OK. I believe the calculation of warning is 10% of remaining time left or less, as set in Asset Management settings.

    I believe you might have also asked a question before about how dell provides multiple warranties for a single item. What I did is to find the earliest start and latest end date for any entitlement, and then concatenate the details of each into the notes of a single warranty object that uses those earliest and latest dates. I excluded the ServiceLevelCode type of ‘DL’ as these seem to have a start and end date that is set to some min or max value.

    Here is the Powershell Script, with some explanation of where I used Published Data, as that doesn’t translate well out of Orchestrator:

    <p>$url = “https://sandbox.api.dell.com/support/assetinfo/v4/getassetwarranty/{PublishedData: Hardware Asset Serial Number}?apikey=<key>”
    
        $ExistingWarranty = {PublishedData: Number of existing Warranty Objects for the Asset}
        $Request = Invoke-RestMethod -URI $url -Method GET -contenttype ‘Application/xml’
        $StartDate = ([DateTime]::Now).AddDays(10000)
        $EndDate = ([DateTime]::Now).AddDays(-10000)
        $StartDateString = ""
        $EndDateString = ""
        $DaysLeft = 0
        $Status = "OK"
        $Description = ""
        foreach ($Entitlement in ($Request.AssetWarrantyDTO.AssetWarrantyResponse.AssetWarrantyResponse.AssetEntitlementData.AssetEntitlement | where ServiceLevelCode -NE 'DL'))
        {
            If (([DateTime]$Entitlement.StartDate) -lt $StartDate)
            {
                $StartDate = ([DateTime]$Entitlement.StartDate)
                $StartDateString = $StartDate.ToShortDateString()
            }
            If (([DateTime]$Entitlement.EndDate) -gt $EndDate)
            {
                $EndDate = ([DateTime]$Entitlement.EndDate)
                $EndDateString = $EndDate.ToShortDateString()
            }
    
            $Description += (([DateTime]$Entitlement.StartDate).ToShortDateString() + " - " + ([DateTime]$Entitlement.EndDate).ToShortDateString() + " : " + $Entitlement.EntitlementType + " : " + $Entitlement.ServiceLevelDescription + "`r`n")
        }
    
        $today = [DateTime]::Now
        $DaysLeft = ($EndDate - $today).Days
        if($DaysLeft -lt 0)
        {
           $DaysLeft = 0
           $Status = "Expired"
        }
    
        if($DaysLeft -ne 0)
        {
           if((($DaysLeft / (($EndDate - $StartDate).Days)) * 100) -lt 10)
          {
               $Status = "Warning"
          }
        }<br></p>

  • Eric_KrasnerEric_Krasner Customer Advanced IT Monkey ✭✭✭
    Answer ✓
    I would rather have the program calculate the Status and days left. 

    I am told that this update will happen nightly if I would just be patient.
Sign In or Register to comment.