mercoledì 22 maggio 2019

Multiple models , how to download drivers (HP softpaqs) using Powershell script

As usual you need HP Client Management (Powershell) Script Library available here https://ftp.hp.com/pub/caps-softpaq/cmit/hp-cmsl.html

download and install them on the PC where you want to download softpaqs

my idea is to create a main folder , such as C:\SoftpaqRepository1.2

then a folder where to save all softpaqs of several models , for the same OS version.  in my case I created C:\SoftpaqRepository1.2\win10_1809

you must intialize the folder as a Softpaq Repository:
cd C:\SoftpaqRepository1.2\win10_1809
initialize-repository

no need to initialize anymore win10_1809 folder in the future.

in this folders I will download softpaq for several models, I got more than 600 softpaqs with my models list.


My script "Synchronize_repository1.2.ps1" does these steps:

First phase: creation of repository.json file

  1. create an array containing modesl list and its sys ID , ex ("840G5_1809","83b2"), ( I have 50 lines )
  2. cd C:\SoftpaqRepository1.2\win10_1809
  3. Add-RepositorySyncFailureRecipient
  4. Set-RepositoryNotificationConfiguration 
  5. using a loop , for each model in the array add a filter for Windows 10 1809 , for all softpaq categories: Add-RepositoryFilter -platform $sysid -os win10  -osver 1809
Second Phase: download all softpaq for all models listed in the array. It could take minutes or hours
  1. Invoke-RepositorySync 

finally  hundreds spxxxx.exe and spxxxx.cva file are saved in "C:\SoftpaqRepository1.2\win10_1809"

PS script creates a  win10_1809_backup folder too. files are not copied but hardlinked using ln.exe
Download lx.exe from http://schinagl.priv.at/nt/ln/ln.html and save it into C:\SoftpaqRepository1.2

download also Gawk.exe from https://sourceforge.net/projects/gnuwin32/files/gawk/3.1.6-1/gawk-3.1.6-1-setup.exe/download?use_mirror=datapacket&download=

copy gawk.exe to "C:\SoftpaqRepository1.2\win10_1809"

Third Phase: for each model in the array , script does an hardlink copy of all softpaqs in a folder named as the model string defined in the array.

as  "C:\SoftpaqRepository1.2\win10_1809" folder , in my case contains 80GB of data, instead of copying the files I use hardlink. this is fundamental otherwise your storage will run out of space very quickly.
  • "C:\SoftpaqRepository1.2\win10_1809\Models" is created
  • scripts create a folder for each model .  Folder will be labeled using model name written in the array ( "C:\SoftpaqRepository1.2\win10_1809\Models\840G5_1809")
  • creates hardlink of all files from win10_1809 to new folder (ex Models\840G5_1809) 
  • create a repository.json for this specific model in the model folder ("C:\SoftpaqRepository1.2\win10_1809\Models\840G5_1809\.repository\repository.json")