Jump to content
DarrenDK

Computer Warranty Updater (HP/Dell/Lenovo)

Recommended Posts

Posted (edited)
  1. Ensure PowerShell version 4.0 or higher is installed on the LabTech Server itself (Needed for Invoke-RestMethod to not prompt for credentials)
  2. Extract LabTechWarrantyUpdaterModules.zip to C:\Program Files\WindowsPowershell\Modules
  3. Import Update-MissingWarranties.xml script into Automate, ignore warnings about version mismatch
    1. 11 - Tools->Import XML Expansion
    2. 12 - System->General->Import->XML Expansion
  4. Unrestrict the script execution policy on your LabTech Server
    1. Set-ExecutionPolicy Unrestricted -Confirm:$false -Force
  5. 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. 
  6. 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
  7. Open the Manage Plugin
    1. 11 - Click the Connectwise button on the top of the main LabTech Interface
    2. 12 - System->Manage Integration
  8. Set Manage Plugin to map the following fields (See screenshot below)
    1. PurchaseDate to Computer.Asset.TagDate
    2. WarrantyExpiration to Computer.Asset.WarrantyEndDate

LabTechWarrantyUpdaterModules.zip

Update-MissingWarranties.xml

ManageAsssetFieldMapping.png

Edited by DarrenDK
words
  • Like 1
  • Thanks 7

Share this post


Link to post
Share on other sites
Posted (edited)

Thanks for posting this Darren. My thoughts on the install process to make it even easier for people is as follows.

For step 2 you need to extract the directories from the zip file into c:\program files\WindowsPowershellModules on the Automate server.

Step 2a would be to install the file in Automate - (the last bit of line 2 is missing a return/a couple of words).

Step 2.12 also has two lines running together.

   In Automate 12, you need to use System/General/Import/XML Expansion 

In my case I got a message that the script was from a newer version of Labtech (ironically enough they are not using the software name!). We are using Automate 12.0.327 Patch 5

Step 6 would be to select System/Connectwise Manage.

In step 6.1 There are 3 Purchase Date fields. You only need to update the Computer one. Same for the WarrantyExpiration

 

I've run the powershell script on the server (thats a great way to include a script to run) and it went through and updated several machines. Eventually it just seemed to stop. Not sure what it's currently doing - I suspect it's waiting for a timeout?

It looks like you've hardcoded your api into the code  - do we need to register for our own api so we don't run against your api limits?

Finally I can't find where the information retrieved from the script shows up in Automate. I've got to be missing something obvious here!

 

Looks like a great step and also a good pointer on creating some powershell/api intergrations for myself.

Thanks for all your hardwork and willingness to share.

Edited by absoblogginlutely!
Added thanks

Share this post


Link to post
Share on other sites
Quote

I've run the powershell script on the server (thats a great way to include a script to run) and it went through and updated several machines. Eventually it just seemed to stop. Not sure what it's currently doing - I suspect it's waiting for a timeout?

My logging here could be better. I may update the script to include more verbose output. The HP API is the one that has the most anal rate limits. Basically you submit all the serial numbers you want to it as a batch job, then it tells you about how long the job will take, and you're not supposed to poll the API again until that time has elapsed, otherwise it will rate limit you and the job gets cancelled.

Quote

It looks like you've hardcoded your api into the code  - do we need to register for our own api so we don't run against your api limits?

I don't think this will be a problem but if it turns out to be I'll post instructions on how to get these keys.

Quote

Finally I can't find where the information retrieved from the script shows up in Automate. I've got to be missing something obvious here!

OK so the funny part about this is that I also can't find where it puts the warranty end date in the interface! This is why I decided to include the bit about syncing it to Manage. You can then use existing expiration workflow rules to trigger tickets opening or whatever you want. I have custom reports that pull these fields for QBRs.

If you open a computer and click Show Details on the top, you can find Asset Date which is going to be the purchase date.

I looked at this from the perspective of the database and placed the data in the fields that seemed to make the most sense.

Share this post


Link to post
Share on other sites

Thanks Darren - after I posted this I realised it was sending it to Connectwise based on the fact that I had to set up the sync. I can confirm it is working and updating the dates correctly.

My initial run did eventually complete but there was a long time (probably around 10 minutes?) between the last id being updated on screen and the script completing. I made use of the time by hunting for the data in Automate 😉

Great job!

Share this post


Link to post
Share on other sites

Fantastic addition to our onboarding process! I can confirm the initial run completion delay. We have 4100+ agents in Automate, and I've been sitting with a PowerShell ISE cursor blinking for around 35 minutes so far. Based on the ComputerID it's stopped on (4197), it seems to be almost complete, but after reading the previous comments I'm hesitant to Ctrl+Break it for fear of missing any queued IDs.

I see that the assorted functions within the script query to only return devices in which the warranty fields are empty, so I'm assuming that if I must break and re-run the script locally it will only attempt to process machines missed by the first run. If there's any reason I shouldn't re-run it locally to catch any stragglers, please let me know.

Great work, and the installation instructions were spot-on!

Share this post


Link to post
Share on other sites

Darren, 

Thank you so much for sharing this! I have just 1 question, when I ran the initial PS script on my LT server, It ran for a while without issue, but when it got to the Lenovo section, it started prompting me for credentials. Did I screw something up? 

Share this post


Link to post
Share on other sites
Posted (edited)

Thanks for this script, it works great.

I notice that in the beginning the script always failed on the same function (Update-MissingHPWarranties). The HP JobResponse estimatedTime was 20296 for 1000 workstations. I reduced the number with a LIMIT on the SQL and then I realize that we have some items with a blank SN, I am not sure if that breaks the script under Update-MissingHPWarranties but I put a filter in the SQL query.

This was my final SQL query:

$HPComputers = get-Labtechdata -query "select BiosVer from computers where biosmfg like 'h%p%' and (warrantyend = 0 or assetdate = 0) AND BiosVer != '' LIMIT 200"

I add these entry to know more about the time:

After the JobResponse:

Write-Output "HP JobResponse estimatedTime: $JobDelay JobID: $JobID"

After Assert-LabtechQuery:

Write-Output "UPDATE: '$($_.sn)' WarrantyEnd='$($_.endDate.SubString(0,10))', AssetDate='$($_.startDate.SubString(0,10))' "

 

I am not sure if the blank items break the function or were a timeout for too many items. I leave it with 200 items at the moment.

Thanks again for this script and this is my little apportation.

 

 

Edited by vgarza

Share this post


Link to post
Share on other sites

Well, I was working with my list and I got this error message:

 

Update-MissingHPWarranties -HPAPIKey "TyI6keB5L14YfiYjXWmx0XExavKZJDAf" -HPAPISecret "z0VOHaEwkcg0FUUt"
Invoke-RestMethod : {"fault":{"faultstring":"Rate limit quota violation. Quota limit exceeded. Identifier : 9536adec-74c9-460d-95ce-e2e3ae995276","detail":{"errorcode":"policies.ratelimit.QuotaViolation"}}}
At line:67 char:20
+     $JobResponse = Invoke-RestMethod -Method Post -body ($HPSNs | ConvertTo-Json ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand
PS C:\Users\vgarza> 

 

I will make a research, if someone already resolved this, I will appreciate the help.

Share this post


Link to post
Share on other sites
Posted (edited)

I tried this and the first part of the script was working but later it started spitting out this pop-up. If I hit cancel it just keeps reappearing. I ended up killing ISE in task manager to get it to go away.

I see. I narrowed it down to the Update-MissingLenovoWarranties function. Once that is commented out the script seems much happier. I'm not sure yet how to make the lenovo section work.

 

image.png.1250165e96c73d05900851720e807823.png

Edited by bbrendon
  • Thanks 1

Share this post


Link to post
Share on other sites
22 hours ago, bbrendon said:

I tried this and the first part of the script was working but later it started spitting out this pop-up. If I hit cancel it just keeps reappearing. I ended up killing ISE in task manager to get it to go away.

I see. I narrowed it down to the Update-MissingLenovoWarranties function. Once that is commented out the script seems much happier. I'm not sure yet how to make the lenovo section work.

 

image.png.1250165e96c73d05900851720e807823.png

If you are getting this credential prompt, upgrade Powershell to version 5, or at least 4 but you might as well use 5. This is a known bug in Powershell 3.0 that ships with Server 2008 R2.

Share this post


Link to post
Share on other sites

How can I only have just seen this what a awesome script. Just looking through the files where would you go to add a new / replace your  api code as I can't see that anywhere. Thanks in advance guys.

Share this post


Link to post
Share on other sites
48 minutes ago, mattgreen said:

How can I only have just seen this what a awesome script. Just looking through the files where would you go to add a new / replace your  api code as I can't see that anywhere. Thanks in advance guys.

The Powershell that does the magic is inside of the LT script called "Update-Missing Warranties" which is under Immense Networks Scripts folder.

You will find the API keys towards to bottom of that script. I'm not sure if it is 100% necessary to get your own key. I'm pretty sure Warranty Master is just using one key for all their clients. I think that's sort of the concept behind giving them to developers. Y'all can just use my keys until they shut us down lol.

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

×