Automating HP Imaging Assistant
Automating HP Imaging Assistant
Written by Simon Firth - Digital Workspace Engineer
I joined the Dunelm family back in Feb 2022 and to be honest, I’ve never looked back. Once of my first tasks was to automate the way HP Imaging Assistant was deployed to the machine and ran on a regular basis.
And what a way this script was born. After breaking down on my way to work and waiting for recovery, I thought this would be the ideal time to create this script.
First thing I need to do was to check if there was a folder on the root of C: Drive. This folder was the remenants of the manual installation of HP Imaging Assistant. To do this I wrote the following code:
The variable $Folder, would set the location of the folder I wish to check for. The next line would check if the folder existed. With the third line then removing the folder if found.
The next part of the script will create the new folder, will wait for 10seconds, then set the location to this folder:
This is the location where we will install and extract using the following line:
this will install the latest copy directly from HP, and extract the content which we will be using later on.
And this is where the fun began. I spent so much time on the next part trying to get this to work. I have found a new admiration for programmers old and new. I wanted the option of copying 2 scripts from a central location onto the local machine. I first thought about using $source and $destination variables, which would work locally on my machine, but could I get it work on a remote machine. The simple answer was no, with a few expletives inserted here and there.
After some time researching the other options, and help from a colleague, I was able to put together the following part. The scripts would be copied from a storage blob from Intune with the following functions:
DriversUpdate:
FirmwareUpdates:
The above functions will copy the content from the blob storage using the Universal Resource Identifier (URI) and the Storage Access Signature (SAS). These functions are simple called by the function name:
The body of the script is completed. This allows all that is needed to be copied over to the local machine. The next part allows all the above to be ran locally.
领英推荐
So going back to the 2 scripts we copied over. The DriversUpdate and FirmwareUpdates.ps1. This is the script that makes all the above work under a sceduled tasks.
Driver Update:
This scheduled task is ran over 12 weeks, and due to the way HP Imaging Assistant works, it looks directly at HP for the most up to date drivers. The scheduled task is split into 4 parts:
$DriverTaskName: This is the name of the task
$DriverTaskPrinicpal: This sets the -UserType and -LogonType.
$DriverSchedule: This will create the task, and executes along with the location of the powershell.exe
$DriverTrigger. This set’s the trigger, in this case -weekly syntax is used with -WeeksInterval set to 12, -At set to 9am and -DaysOfWeek set to Wednesday
The last line will register the scheduled task with -TaskName $DriverTaskName, -Action $DriverSchedule, -Trigger $DriverTrigger and finally -Principal $DriverTaskPrincipal
Firmware Updates:
This scheduled task is ran over 4 weeks, and due to the way HP Imaging Assistant works, it looks directly at HP for the most up to date drivers. The scheduled task is again split into 4 parts:
$FirmwareTaskName: This is the name of the task
$FirmwareTaskPrinicpal: This sets the -UserType and -LogonType.
$FirmwareSchedule: This will create the task, and executes along with the location of the powershell.exe
$FirmwareTrigger. This set’s the trigger, in this case -weekly syntax is used with -WeeksInterval set to 4, -At set to 9am and -DaysOfWeek set to Wednesday
The last line will register the scheduled task with -TaskName $FirmwareTaskName, -Action $FirmwareSchedule, -Trigger $FirmwareTrigger and finally -Principal $FirmwareTaskPrincipal.
Once the all the above has been copied and created on the local machine, we need to run this as soon as completed. This was completed by the following 2 lines of code:
Once this was packaged in Intune and deployed, I felt a great sense of achievement. To say this was my first script from scratch and it, well, worked after some prodding, poking, expletives and a lot of wondering why I started this, I was able to see the end game. This will not deter me from my next script, which is already in the pipeline.