Jump to content
DarrenDK

Computer Warranty Updater (HP/Dell/Lenovo)

Recommended Posts

21 hours ago, maxgruv said:

Just confirmed that the WarrantyEnd dates are populating in Automate's database but not syncing to computer Expiration Date fields in Manage. The API field mappings are set as instructed in the Manage plugin, so just something is not communicating across properly. @DarrenDK, any suggestions?

I went through this with support a few months back and the official word is that the Expiration field can't be synced. You can however update it via the Manage API directly.

$BaseUri = "https://@ManageURL@/v4_6_release/apis/3.0/company/configurations/@ManageId@"


$ContentType = "application/json"

$Headers=@{
        "Authorization"="Basic @APIKey@"
        }

$action = @"
[
{
    "op": "replace",
    "path": "/warrantyExpirationDate",
    "value": "@WarrantyEndDate@"
}
]
"@

try{

$JSONResponse = Invoke-RestMethod -URI $BaseURI -Headers $Headers -Body $action -ContentType $ContentType -Method Patch -ErrorAction Stop

    Write-Host "Successfully updated warranty end date to" $JSONResponse.warrantyExpirationDate

}catch{

    write-host "Something went wrong." $_.Exception.Message

}

 

 

Share this post


Link to post
Share on other sites

Thanks Joe.

I'm not sure what to do with that though. How would I use the above - is it something I write into a Powershell script (and then can use in LT scripting)?

Share this post


Link to post
Share on other sites
7 hours ago, noahsmybro said:

Thanks Joe.

I'm not sure what to do with that though. How would I use the above - is it something I write into a Powershell script (and then can use in LT scripting)?

+1

Share this post


Link to post
Share on other sites
10 hours ago, noahsmybro said:

Thanks Joe.

I'm not sure what to do with that though. How would I use the above - is it something I write into a Powershell script (and then can use in LT scripting)?

I run that in an Automate script using the Execute Script function. IIRC, you can register for your API auth key/find out where to get it via (https://developer.connectwise.com)

I use EDF's to track computers that have had their warranty information updated in Manage and run a nightly maintenance script that loops through the computers, gathers the Manage ID from the plugin table, then runs the powershell via a function script to push the warranty information via the API. Anything that is synced to Manage (Network Devices!) can be updated in similar fashion, as you will have the Manage ID in the associated plugin table on your Automate server.

 

Share this post


Link to post
Share on other sites

Word on the street is that the WarrantyEnd field is being deprecated and maybe that is why it no longer syncs.

Doing an EDF would be relatively trivial to add to this codebase. Basically just add to the extrafield table a warranty end field, and then upsert entries into the extrafielddata table for each computer. There should be enough reference code inside the Powershell of the script for you to get a feel for how I'm running sql against the database.

I'm probably not going to get to this for a while, but if someone wants to take a stab at it and send it to me, I'd happily update this post with it.

Share this post


Link to post
Share on other sites

I've created the EDF, and the relevant code - really just a very trivial SQL query - is in my post above.

I would like to get this data into CWM though. I'll give your guidance a go, Joe, thanks for that. And hopefully if the WarrantyEnd field is being deprecated there is somewhere else I can write this to in CWM that makes sense.

Share this post


Link to post
Share on other sites
On 1/23/2019 at 9:21 PM, Joe.McCall said:

I run that in an Automate script using the Execute Script function. IIRC, you can register for your API auth key/find out where to get it via (https://developer.connectwise.com)

I use EDF's to track computers that have had their warranty information updated in Manage and run a nightly maintenance script that loops through the computers, gathers the Manage ID from the plugin table, then runs the powershell via a function script to push the warranty information via the API. Anything that is synced to Manage (Network Devices!) can be updated in similar fashion, as you will have the Manage ID in the associated plugin table on your Automate server.

 

Joe,

 

Can you share your work with us minus the API key? 

 

Thank you.

Share this post


Link to post
Share on other sites
On 2/5/2019 at 12:04 PM, marmfield said:

Joe,

 

Can you share your work with us minus the API key? 

 

Thank you.

I run a modified version of the script from this thread nightly. It executes the warranty update portion on the Automate side, then calls a function script to recurse through all computers that are missing the "Warranty Updated in Manage" EDF check. For each found computer, it executes a second function script to perform the actual API update call to push the information into Manage.

You can use this method to push to other configs as well (think network devices!). The HP warranty lookup function works for printers as well as computers, with a little bit of tweaking and customization.

CWA - SQL Function - Update Computer WarrantyExpiration in Manage.xml

CWA - SQL Function - Update WarrantyExpiration in Manage.xml

Share this post


Link to post
Share on other sites
On 1/23/2019 at 10:21 PM, Joe.McCall said:

I run that in an Automate script using the Execute Script function. IIRC, you can register for your API auth key/find out where to get it via (https://developer.connectwise.com)

I use EDF's to track computers that have had their warranty information updated in Manage and run a nightly maintenance script that loops through the computers, gathers the Manage ID from the plugin table, then runs the powershell via a function script to push the warranty information via the API. Anything that is synced to Manage (Network Devices!) can be updated in similar fashion, as you will have the Manage ID in the associated plugin table on your Automate server.

 

@Joe.McCall

 

I have registered and logged into https://developer.connectwise.com.

Could you please point me in the right direction and let me know where I can find the API key, and how to implement this in Automate?

I keep getting: Something went wrong. The remote server returned an error: (400) Bad Request.

Much appreciated & TY

 

Start    SSI\Testing\CWA - SQL Function - Update WarrantyExpiration in Manage
IF    True         Time Taken:  1.1406072
L1    Execute Script         Time Taken:  1.1406072
L3    Script Log Message    Message (P1): Woooo - Something went wrong. The remote server returned an error: (400) Bad Request.
Time Taken: 15.1879583

Start	CWA - SQL Function - Update WarrantyExpiration in Manage
IF	True	 	Time Taken:  1.1406072
L1	Execute Script	 	Time Taken:  1.1406072
L3	Script Log Message	Message (P1): Something went wrong. The remote server returned an error: (400) Bad Request.
  	Time Taken:  15.1879583

 

Edited by Dave M

Share this post


Link to post
Share on other sites

 

18 minutes ago, Joe.McCall said:

https://developer.connectwise.com/Products/Manage/Developer_Guide/Authentication

This part of the site has the info.

You need to setup an API member in Manage. There’s a global parameter in the script that runs the API update for the base64 authentication string. It has a dummy value right now, hence the error.

It works! THANK YOU

 

For anyone else trying this,

You need to put in companyid+publickey:privatekey at https://www.base64encode.org/, then paste the full output in the parameter.

 

Edited by Dave M

Share this post


Link to post
Share on other sites

Is anyone having issues with the HP lookup?  I am getting the following when running the script in ISE:

 

Invoke-RestMethod : The operation has timed out
At line:382 char:21
+     $AuthResponse = Invoke-RestMethod -Method Post -Uri $uri -headers $headers - ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Invoke-RestMethod], WebException
    + FullyQualifiedErrorId : System.Net.WebException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand
 
Invoke-RestMethod : The operation has timed out
At line:388 char:20
+     $JobResponse = Invoke-RestMethod -Method Post -body (ConvertTo-Json $HPSNs)  ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Invoke-RestMethod], WebException
    + FullyQualifiedErrorId : System.Net.WebException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand

Share this post


Link to post
Share on other sites

Thanks so much for building this! 

I noticed that the warranty end date for Dell computers is showing as the Dell Digital Delivery end date. Is there a way to exclude that and use the hardware warranty end date?

Share this post


Link to post
Share on other sites
Posted (edited)
22 hours ago, telligent said:

Thanks so much for building this! 

I noticed that the warranty end date for Dell computers is showing as the Dell Digital Delivery end date. Is there a way to exclude that and use the hardware warranty end date?

Can you provide me the service tag that is giving you the issue? I had a similar issue recently because I was filtering the "AssetEntitlementData" to only show standard warranties so it wasn't including ProSupport. I removed the filter but evidently this has allowed for Digital Delivery to sneak in.

Edited by DarrenDK

Share this post


Link to post
Share on other sites
Posted (edited)

The few Dell Warranty end dates I've looked at so far are not correct.  I ran it and found one Warranty expiration date to be off by 5 years and 2 days and another off by 6 years and 6 months. 

Edited by hugoh

Share this post


Link to post
Share on other sites
16 hours ago, hugoh said:

The few Dell Warranty end dates I've looked at so far are not correct.  I ran it and found one Warranty expiration date to be off by 5 years and 2 days and another off by 6 years and 6 months. 

When you pulled the warranty information manually, were there other expirations listed? If you want to PM me the service tag I can dig into it. There was someone else saying the warrantyend dates were inaccurate but I haven't found a test case yet.

Share this post


Link to post
Share on other sites

I finally got powershell updated to v5 and imported the XML file  - For step 5, under scripts I have a InmyBot folder and a Immense Networks Scripts folder, but they are empty. I'm on 2019.2 and just downloaded the files today.

Edited by michaelp_IIS

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×