Automatically Retrieve Dell Warranty Info and Import it into PDQ Inventory Custom Fields
One of my coworkers was tasked with pulling reports of old computers that need to be replaced which sent me down a rabbit hole of trying to automatically determine that based on data in PDQ Inventory. I couldn't find a great solution so I decided to automate importing some data into PDQ to make this work.
Here is the link to the GitHub repo: https://github.com/jlukenichols/KUDellWarrantyChecker
Basically, it does this:
- The script looks at a CSV file containing every Dell computer in your PDQ Inventory. It must have the Computer Name and Computer Serial Number fields, but it can contain additional fields as well if you want. I have this on an auto-report which saves the CSV file to a UNC path on a network share every night at 6:00 PM. If you do an auto report make sure to NOT include the date in the file path and make sure to overwrite old files. I have the filters on the report set to this:
- The script iterates through each service tag in the CSV file, performs a Dell API lookup to grab its warranty data, and saves that data into an output CSV file. Right now the data grabbed is "Ship Date" and the device's entitlement (warranty) end dates. Because a computer can have several entitlements it just grabs the maximum of all the dates returned. Some of my devices had a 1-year initial entitlement and a 3-year extended entitlement so I just wanted to know when all of its warranties would be expired.
- The script imports the Dell warranty data from the newly created CSV file and imports it into PDQ Inventory as custom fields. It assumes that you have already created the custom fields with date/time data types. If you want to mirror my setup then create the custom fields like this:
This code is available for anyone to use, although you will need to apply for your own Dell API key on Dell TechDirect: https://techdirect.dell.com/Portal/APIs.aspx
If you run into issues getting your API key you should email APIs_TechDirect@dell.com. I know my request to gain access to the API portal was denied several times with an utterly useless error code being emailed to me, and the issue turned out to be that I had no Dell service tags or Dell customer number associated with my account. I ended up reaching out to them via email and just giving them some of our Dell service tags with which they were able to look up my Dell customer number and associate it to my account. After that I got into the API program without issues.
If anyone has any questions about the script or needs help setting it up for their environment let me know.
Comments
Is set to 30, which I think is how it is straight from the GitHub repo
Could you take screenshots of your scheduled task configuration and post them here? If you don't want to post them publicly you can email me at J.Luke.Nichols@gmail.com instead
Thank you for all of your work to this project Luke, it has been very helpful in my learning of PDQ & Powershell.
Glad to hear it was helpful, Jonathan.
Hi Luke, I am not sure how feasible this is but is there a way to exclude the PDQ part of your PS so it stops at the creation of the export CSV file? We're not PDQ users but are desparately trying to get an export of Dell service tags.
I get to this point and it fails, I queried with Dell if it is an issue with the API secret, waiting to hear back from them.
Dave,
It is certainly possible to run this codebase completely outside of PDQ, in fact the only step in the whole script that interacts with PDQ at all is line 191 where it imports the output CSV into PDQ. You could just comment out or remove that line and it would not interface with PDQ:
& $PDQInvExecPath ImportCustomFields -FileName "$FullPathToOutputCSV" -ComputerColumn "Computer Name" -CustomFields "$ShipDateCustomFieldName=$ShipDateCustomFieldName,$EntitlementEndDateCustomFieldName=$EntitlementEndDateCustomFieldName" -AllowOverwrite
The script also makes some assumptions that you're using PDQ Inventory to generate the original input CSV, but if you can produce an input CSV file in the same format by other means then it will certainly work. Simply look at the "ExampleInput.csv" file and, if you have a different solution that can produce data in that format, you can use any method you want.
Based on your screenshot above it looks like you're having troubles with retrieving your API token. Please verify your $DellWarrantyAPIKey and $DellWarrantyAPIKeySecret values in your CustomSettings.ps1 file. You may have a typo, you may have swapped the key and secret, you may have forgotten to remove the parentheses, etc.
Hi Luke,
Just wondering if you can help, I can't seem to get this to work at all, I keep getting errors when running KUDellWarrantyChecker. Can you just explain the purpose of the customsettings file which I have amended and when do I run it? Before running KUDellWarrantyChecker? Do I need to amend anything in KUDellWarrantyChecker? I'm clearly doing something wrong so any assistance would be most appreciated.
Many thanks,
Dave
Dave,
You don't manually run CustomSettings.ps1 at all. Just clone DefaultSettings.ps1, rename it to CustomSettings.ps1, and edit in all of your settings. When you run the main script, it imports the CustomSettings.ps1 file automatically. I know this is confusing, but I did it this way so your CustomSettings.ps1 file doesn't get clobbered if you want to update the git repo in-place, although in hindsight I should have named DefaultSettings.ps1 something like "settings.ps1.example" with instructions to create your own settings.ps1 file.
If you can share some of the errors, I may be able to help. I'm not sure if you're the same Dave as the previous reply since your forum username seems to be different, but if you are, then you'll also need to comment out this line if you don't want the script to attempt to import the data into PDQ:
& $PDQInvExecPath ImportCustomFields -FileName "$FullPathToOutputCSV" -ComputerColumn "Computer Name" -CustomFields "$ShipDateCustomFieldName=$ShipDateCustomFieldName,$EntitlementEndDateCustomFieldName=$EntitlementEndDateCustomFieldName" -AllowOverwrite
I am also still unable to run it. Please see error grab below. I have asked Dell to verify the credentials and they say they are fine.
Luke apologies for not responding, I did not get any notifications of comments until today.
Reading your comments I see the below section regarding the key and secret. It's unclear which part of the API goes where. Could you clarify for me how this is entered into CustomSettings file please.
Hi Luke,
Thanks for getting back so quickly. I'll call myself Dave S to avoid any confusion with the other Dave, we're very popular! :-)
When I run the KUDell ps script I just get a load of errors, please see screenshot
Regards,
Dave S
PS I do want it to write back to PDQ.
It breathes
Just getting a few spurious entries but I "think" that is non Dell tags that aren't recognised.
Just for info I did not realise the key and secret are from the same field in the Dell API. The key is the first data part and the secret is the bit in the parenthesis. Once I separated them and removed the parenthesis it worked great.
Thanks Luke, this is great for us.
Dave P
Hi Luke,
Quick upate, the script ran last night and it worked fine, all of the data was retrieved from Dell and input back in to PDQ.
However, I am still getting the 'write log' error, how do I get rid of this?
Finally, can I import the date without the time or is this mandatory?
Many thanks for your help.
Dave S
@Dave (no S), glad to hear it's working.
david.skingley, It looks like the script is having trouble dot-sourcing the Write-Log function. There should be a "functions" folder in the same location where your "KUDellWarrantyChecker.ps1" script is located, and that folder should contain a script named "Write-Log.ps1". Do you have that folder and script? If you cloned the repo from Github it should be there, but if you just downloaded the main script file you may have missed it.
Edit:
I would recommend against messing with the date format, I've designed the script to match the date format expected by the "DateTime" custom field data type in PDQ. It may be possible to erase the time portion or set it to 00:00:00 but I wouldn't advise it. Is there a particular reason that you don't want the time included?
Hi Luke,
You were right, I missed the functions folder! Everything is now working as expected thank you.
As for the date/time, it was our Asset manager that uses PDQ inventory on a daily basis that requested the omission of the time. It was just a personal preference and not a funtional reason. I will let him know it's best to keep it in.
Many thanks again for you help.
Regards,
Dave S