connochio / Powershell.Modules

A collection of home-made PowerShell modules
GNU General Public License v3.0
12 stars 10 forks source link

Automate the install #1

Closed apollo753 closed 3 years ago

apollo753 commented 3 years ago

Connochio

Is it possible to automate the install of your Dell Warranty Check? I would like to create an SCCM package to deploy this to our PCs on our network.

Instead of asking for the api key and secret key could this not be a one line entry or read from a text file?

Thank you Dave

connochio commented 3 years ago

Yep, this can be done using a modified version of the module.

Please see the newly created SCCM folder under the root of this Git:

  1. Download the Get-DellWarranty.ps1 script
  2. Create a package within your SCCM instance with the folder that contains the script as a content source
  3. Create a program under that package, and within 'Command Line' enter this: %Windir%\Sysnative\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -Command ".\Get-DellWarranty.ps1 -ApiKey xxxxx -ApiSecret xxxxx" Replacing xxxxx with your key and secret without any quotations or anything

You can then deploy it out to assets to run the script. One benefit of this approach is it keeps the API key and Secret from being stored directly on the client device.

To have it picked up by SCCM within the hardware inventory, you will need to amend your Hardware Inventory classes within your default client settings.

Please let me know if this works for you.

apollo753 commented 3 years ago

I just tried this and I can't get it to work. Do I also need a new psm1 file? Before putting this in SCCM I am trying to execute on my PC first. DellWarranty

Putting the api key as before it works fine see below DellWarrantygood

Thank you for you help on this!

connochio commented 3 years ago

I think I can see the issue here.

The SCCM script is a stripped down version of the module and does not have any switches apart from the -ApiKey and -ApiSecret and shows no output upon completion due to being run in the background by SCCM. By using these switches, it doesn't store the API information on the local machine by design, to avoid any issues with security of the key.

It looks to be that the .ps1 ran successfully in your first screenshot before it was ran with the -show tag, which left the authentication call to use a blank API and Secret.

Please remove any entries from HKLM:\Software\WARRANTY and re-run the first command using just the -ApiKey and -ApiSecret switches as a test.

If the registry is populated after this, then the script has run successfully.

apollo753 commented 3 years ago

Okay it works in the SCCM image during the OSD. I assumed it did not work because the system was asking for the key. But I just looked on a deployed system that I was testing and the registry is branded. I only need this done once so it is perfect, when the api changes I will just update the SCCM task sequence. Thank you so much for your help!

connochio commented 3 years ago

No worries! Glad I was able to help!

I will try to keep this up to date if Dell changes their API, as that happened with a previous version of this module. I have also created a new Git repo for the SCCM deployable version of this script at https://github.com/connochio/Powershell.SCCM for any future development or issues :)