Jump to content
DarrenDK

Computer Warranty Updater (HP/Dell/Lenovo)

Recommended Posts

Getting the following while running HP portion:

Update-WarrantyInLabTech : Cannot process argument transformation on parameter 'EndDate'. Cannot convert null to type "System.DateTime".
At line:247 char:104
+ ... terID -ShipDate $WarrantyInfo.ShipDate -EndDate $WarrantyInfo.EndDate
+                                                     ~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Update-WarrantyInLabTech], ParameterBindingArgumentTransformationException
    + FullyQualifiedErrorId : ParameterArgumentTransformationError,Update-WarrantyInLabTech

 

UPDATE

Changed last line in Update-MissingHPWarranties to this:

Update-WarrantyInLabTech -ComputerID $ComputerID -ShipDate $WarrantyInfo.ShipDate -EndDate $WarrantyInfo.WarrantyEnd #EndDate

Now get error 

Exception calling "Fill" with "2" argument(s): "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 
'{BiosVer=2UAXXXXXX}' at line 1"
At C:\Program Files\WindowsPowerShell\Modules\LabTech\LabTech.psm1:67 char:5
+     $RecordCount = $dataAdapter.Fill($dataSet, "data")
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : MySqlException

 

 

Edited by jamberston
additional information

Share this post


Link to post
Share on other sites

First, thank you for sharing this script.  We were dependent on WarrantyMaster until they pulled their pricing heist which increased our cost 38%/month. 

I too am getting errors on the HP call.  I am using PS v4

Invoke-RestMethod : The request was aborted: Could not create SSL/TLS secure channel.
At line:179 char:21
+     $AuthResponse = Invoke-RestMethod -Method Post -Uri $uri -headers $headers - ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand
 
 

Any help is much appreciated.

Edited by shanna

Share this post


Link to post
Share on other sites

Hey guys,

The HP issues should be fixed. I've also embedded the Lenovo logic into the script so the Lenovo module doesn't need to be installed anymore. You still need my LabTech module.

Please reference the initial post, I have edited it to have the latest versions.

Let me know if this helps!

Edited by DarrenDK
Clarity

Share this post


Link to post
Share on other sites

I just posted another update that should fix the HP thing once and for all. It's going to update HP warranties in chunks of 25.

Share this post


Link to post
Share on other sites
3 hours ago, DarrenDK said:

I just posted another update that should fix the HP thing once and for all. It's going to update HP warranties in chunks of 25.

Looks like something went wrong with attaching the file, it's coming in at 0Kb.

Share this post


Link to post
Share on other sites
Quote

I just posted another update that should fix the HP thing once and for all. I don't have a huge sample set of HPs to test with

Try now

Edited by DarrenDK

Share this post


Link to post
Share on other sites

Hi,

Great work on this script! I'm having a problem which I wonder if anyone else has had. When I run though ISE on the server the first 25 HP serials go through, but all of them after that return an error:

Quote

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

It just cycles then, picks up the next serials but then gives me the same error.

Any ideas?

 

Share this post


Link to post
Share on other sites

@DarrenDK this looks to be an awesome script, and a well written howto! Thank you.

I am however having some issues when I run it, and results are not making it into manage.

When the script runs, it comes back with the following in the log:

# Warranty Lookup Result 
Trimming SerialNumbers
Updating Dell Warranties
% : You cannot call a method on a null-valued expression.
At C:\Windows\Temp\2e98f56d-fe14-11e8-afa9-00155d006e00.ps1:257 char:45
+     $Warranties = $XML.AssetWarrantyResponse | %{
+                                                ~~
    + CategoryInfo          : InvalidOperation: (:) [ForEach-Object], RuntimeE 
   xception
    + FullyQualifiedErrorId : InvokeMethodOnNull,Microsoft.PowerShell.Commands 
   .ForEachObjectCommand
 

Any ideas on what I could be doing wrong?

 

I also noticed the function script (ImmyBot\Function Scripts - Core\Run-PowershellOnLTServer) refers to immense.net. 
What is the function doing when it does this and is it necessary to run?

Share this post


Link to post
Share on other sites
2 hours ago, Dave M said:

@DarrenDK this looks to be an awesome script, and a well written howto! Thank you.

I am however having some issues when I run it, and results are not making it into manage.

When the script runs, it comes back with the following in the log:


# Warranty Lookup Result 
Trimming SerialNumbers
Updating Dell Warranties
% : You cannot call a method on a null-valued expression.
At C:\Windows\Temp\2e98f56d-fe14-11e8-afa9-00155d006e00.ps1:257 char:45
+     $Warranties = $XML.AssetWarrantyResponse | %{
+                                                ~~
    + CategoryInfo          : InvalidOperation: (:) [ForEach-Object], RuntimeE 
   xception
    + FullyQualifiedErrorId : InvokeMethodOnNull,Microsoft.PowerShell.Commands 
   .ForEachObjectCommand
 

Any ideas on what I could be doing wrong?

 

I also noticed the function script (ImmyBot\Function Scripts - Core\Run-PowershellOnLTServer) refers to immense.net. 
What is the function doing when it does this and is it necessary to run?

Hey Matt, I removed immense.net, it was unnecessary. 

The purpose of that script is what it says, to run PowerShell on the LT server. As you can see, the logic is written in PowerShell and needs a place to execute. I couple that with my custom labtech PowerShell module, and it allows me to interact with the database in PowerShell rather than within the rather clumsy LT scripting language.

With regards to your specific issue, it looks like for whatever reason the Dell API didn't return a result. Perhaps the service tag(s) it was passing in were invalid?

Edited by DarrenDK

Share this post


Link to post
Share on other sites
On 12/12/2018 at 12:08 PM, DarrenDK said:

Hey Matt, I removed immense.net, it was unnecessary. 

The purpose of that script is what it says, to run PowerShell on the LT server. As you can see, the logic is written in PowerShell and needs a place to execute. I couple that with my custom labtech PowerShell module, and it allows me to interact with the database in PowerShell rather than within the rather clumsy LT scripting language.

With regards to your specific issue, it looks like for whatever reason the Dell API didn't return a result. Perhaps the service tag(s) it was passing in were invalid?

Thank you! 

Unfortunately I'm still not having any luck.

I ran the script on the server with ISE and I get the below errors. Any pointers in the right direction is appreciated.

#Get-DellWarrantyInfo -ServiceTag @("*******","*******") -APIKey $DellAPIKey2015
Trimming SerialNumbers
Updating Dell Warranties
You cannot call a method on a null-valued expression.
At line:259 char:8
+        New-Object psobject -Property @{"WarrantyEndDate"=[DateTime]:: ...
+        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull
 
You cannot call a method on a null-valued expression.
At line:259 char:8
+        New-Object psobject -Property @{"WarrantyEndDate"=[DateTime]:: ...
+        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull
 
You cannot call a method on a null-valued expression.
At line:259 char:8
+        New-Object psobject -Property @{"WarrantyEndDate"=[DateTime]:: ...
+        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull
 
Updating ComputerID: 92 ShipDate: 12/07/2018 00:00:00 EndDate: 12/06/2021 00:00:00
Updating ComputerID: 91 ShipDate: 12/07/2018 00:00:00 EndDate: 12/06/2021 00:00:00
Updating Lenovo Warranties
Submitting  computers to Lenovo API: *******
Update-WarrantyInLabTech : A parameter cannot be found that matches parameter name 'EndDate'.
At line:348 char:84
+ ... abTech -ComputerID $_.ComputerID -ShipDate $ShipDate -EndDate $EndDat ...
+                                                          ~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Update-WarrantyInLabTech], ParameterBindingException
    + FullyQualifiedErrorId : NamedParameterNotFound,Update-WarrantyInLabTech

I also checked Computers with ID 92 and 92, and they do not have the information populated in manage.

Edited by Dave M

Share this post


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

Thank you! 

Unfortunately I'm still not having any luck.

I ran the script on the server with ISE and I get the below errors. Any pointers in the right direction is appreciated.


#Get-DellWarrantyInfo -ServiceTag @("*******","*******") -APIKey $DellAPIKey2015
Trimming SerialNumbers
Updating Dell Warranties
You cannot call a method on a null-valued expression.
At line:259 char:8
+        New-Object psobject -Property @{"WarrantyEndDate"=[DateTime]:: ...
+        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull
 
You cannot call a method on a null-valued expression.
At line:259 char:8
+        New-Object psobject -Property @{"WarrantyEndDate"=[DateTime]:: ...
+        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull
 
You cannot call a method on a null-valued expression.
At line:259 char:8
+        New-Object psobject -Property @{"WarrantyEndDate"=[DateTime]:: ...
+        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull
 
Updating ComputerID: 92 ShipDate: 12/07/2018 00:00:00 EndDate: 12/06/2021 00:00:00
Updating ComputerID: 91 ShipDate: 12/07/2018 00:00:00 EndDate: 12/06/2021 00:00:00
Updating Lenovo Warranties
Submitting  computers to Lenovo API: *******
Update-WarrantyInLabTech : A parameter cannot be found that matches parameter name 'EndDate'.
At line:348 char:84
+ ... abTech -ComputerID $_.ComputerID -ShipDate $ShipDate -EndDate $EndDat ...
+                                                          ~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Update-WarrantyInLabTech], ParameterBindingException
    + FullyQualifiedErrorId : NamedParameterNotFound,Update-WarrantyInLabTech

I also checked Computers with ID 92 and 92, and they do not have the information populated in manage.

I'm not at a computer right now, but I'm sure I had the same issue and it was because either one on the parameters or variables (can't remember which one) was named EndDate instead of WarrantyEnd (or whatever it should have been). If you don't find it by the time I'm back I'll post an update with the affected line number.

  • Thanks 1

Share this post


Link to post
Share on other sites

I updated 348 to "Update-WarrantyInLabTech -ComputerID $_.ComputerID -ShipDate $ShipDate -WarrantyEndDate $EndDate". and I now get:
 

Updating Lenovo Warranties
Submitting  computers to Lenovo API: PF0ZZLCL
Updating ComputerID: 54 ShipDate: 03/06/2018 00:00:00 EndDate: 05/13/2019 00:00:00
Updating HP Warranties

However it is still not showing anything in Manage.

I'm also still getting the error on line:259 char:8, which is expected as nothing has changed.

Share this post


Link to post
Share on other sites

Grrr.. no matter what I do I can't get it passed this!

Updating Dell Warranties
You cannot call a method on a null-valued expression.
At line:259 char:8
+        New-Object psobject -Property @{"WarrantyEndDate"=[DateTime]:: ...
+        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull
 
You cannot call a method on a null-valued expression.
At line:259 char:8
+        New-Object psobject -Property @{"WarrantyEndDate"=[DateTime]:: ...
+        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull
 
You cannot call a method on a null-valued expression.
At line:259 char:8
+        New-Object psobject -Property @{"WarrantyEndDate"=[DateTime]:: ...
+        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull
 
You cannot call a method on a null-valued expression.
At line:259 char:8
+        New-Object psobject -Property @{"WarrantyEndDate"=[DateTime]:: ...
+        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

 

Share this post


Link to post
Share on other sites

It seems the HP and Lenovo lookups are not working for me. 

I went ahead and signed up for the HP API and got my own API keys but the lookups only work for the first 25 workstations.  Every lookup after that fails.  In my case I changed the group from 25 to 1000.  While it took over 50 minutes to get the results, it grabbed all my HP workstation lookups and updated successfully.

I'm looking into the Lenovo powershell to see if I can figure out why my lookups fail but I greatly appreciate your work on this script.  If I can get this working with the Lenovo, We will be able to drop our Warranty Masters account and save money.

Share this post


Link to post
Share on other sites

Anybody else getting null content for the Dell $WarrantyInfoArray on the latest version? Fails because "-ServiceTag" is null. This is populated using the Get-Chunks function but we don't have enough Dell machines to warranty troubleshooting that part so I've just swapped it out to use the $ComputersMissingWarranty variable. Just a heads up in case somebody looks into it.

 

Edit:

 

And the Lenovo lookup is using -EndDate on line 348 but the parameter is -WarrantyEndDate.

@marmfield that might have something to do with it

Edited by lgs141
Added some info

Share this post


Link to post
Share on other sites
4 hours ago, lgs141 said:

And the Lenovo lookup is using -EndDate on line 348 but the parameter is -WarrantyEndDate.

@marmfield that might have something to do with it

That fixed it for me!  Thanks @lgs141

 

I'll look to see if I get the error you mention when this finishes running.

Share this post


Link to post
Share on other sites

 

 

1 hour ago, marmfield said:

That fixed it for me!  Thanks @lgs141

 

I'll look to see if I get the error you mention when this finishes running.

Hey guys, I just updated the script to include this change, and also fix an issue where I was filtering out non-Next Day warranties on Dell computers (it was filtering out ProSupport warranties)

 

Just download and import the .xml from the first post.

Share this post


Link to post
Share on other sites

@DarrenDK That you for the update!

The Ps script now runs fine and produces results in ISE.

However, I don't see anything updates in Manage.

I have double checked to make sure my mapping is OK, manually ran the script against a machine, and forced an asset sync.

Where else can I look to troubleshoot?

 

 

 

I was able to find this in the executed script log, although it runs fine in ISE:

# Warranty Lookup Result 
Trimming SerialNumbers
Updating Dell Warranties
No Dell computers missing warranty
Updating Lenovo Warranties
Submitting  computers to Lenovo API: 1037921101087
New-Object : Cannot find type [â?TypeName PSObject â?Prop]: verify that the 
assembly containing this type is loaded.
At C:\Windows\Temp\9cffbb28-1850-11e9-bdd6-00155d006e00.ps1:229 char:21
+ ...   $WarrantyInfo = New-Object â?"TypeName PSObject â?"Prop $properties
+                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidType: (:) [New-Object], PSArgumentExcepti 
   on
    + FullyQualifiedErrorId : TypeNotFound,Microsoft.PowerShell.Commands.NewOb 
   jectCommand
 

1/14/2019 6:03:46 PM
ComputerID
Hidden_ComputerID

 

Edited by Dave M
update

Share this post


Link to post
Share on other sites

@DarrenDK Thanks again for sharing this. The script is running on our server and we had our first big test of it this week while onboarding a new client's workstations. However, it appears the script is failing to execute fully so there are a whole whackload of HP computers lacking expiry dates in Manage—although the Purchase Date seems to be populated, oddly enough.

Here is a sample of the log result for these systems. Do we need to do something on remote agents for PS execution policy or something else for this to work?

# Warranty Lookup Result 
Import-Module : AuthorizationManager check failed.
At C:\0e71d6c5-1909-11e9-9ac8-00155d654806.ps1:2 char:1
+ Import-Module LabTech
+ ~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : SecurityError: (:) [Import-Module], PSSecurityException
    + FullyQualifiedErrorId : UnauthorizedAccess,Microsoft.PowerShell.Commands 
   .ImportModuleCommand

Cheers,
Paul

Share this post


Link to post
Share on other sites

I'm still waiting for my ISE command to finish so haven't had an opportunity to play with this yet. But I see a few mentions above of people unable to find the Warranty End Date anywhere in the CWA gui.

I'd expect it would be trivial to add an EDF to display the value. Is there something I'm missing that makes that more complicated than I think?

 

Share this post


Link to post
Share on other sites

Darren, this was great, thanks for it.

I've added an EDF to our Computers window to show the value from the db located at computers.warrantyend.
 

SELECT `warrantyend` FROM computers WHERE computerid=%computerid%;

 

This is an ignorant question, but where in CWM can I see the information?

Share this post


Link to post
Share on other sites

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?

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

×