Powershell command to update driver automatically from Windows Update

8,813

So, if I have understood correctly:

  • You have a number of devices with a certain TouchPad make and model
  • You want to update their TouchPad drivers from Windows Update en masse

I recommend doing this using these two stages.

Stage one: Get the TouchPad driver

This is easy and straightforward. Updates that Microsoft usually propagates through Windows Update are also available on Microsoft Update Catalog website at:

... and this includes device drivers. Search for the drivers you need to install and download it. You'll end up with a .cab file.

Stage two: Inject them

To an offline OS

The question indicates there is OS imaging at work. Hence, I believe it is easier to add the driver (in this case a TouchPad driver) to the images, if those images are .wim images or there is offline access to the OS before being imaged.

Having acquired the driver(s) from Microsoft Update Catalog, place the .cab file(s) of the driver(s) into a folder, e.g. "C:\Test\Drivers", and extract the .cab file(s). The content of each .cab file should go into a subfolder. Then, open Windows PowerShell and use Add-WindowsDriver command to inject the driver(s) to the Windows image.

You might want to update your Windows PowerShell to 5.1 if you are not on Windows 10. Also, you might want to install the latest version of Deployment Tools instead of just using the one that comes with Windows. Deployment Tools are included in Windows Assessment and Deployment Toolkit. Download the online installer (adksetup.exe) which 2 MB. Run it and select Deployment Tools only. It is a 90 MB download.

Now, to add the driver(s) placed in C:\test\drivers as described above, to an offline Windows image mounted on c:\offline, issue the following command in Windows PowerShell:

Add-WindowsDriver -Path "c:\offline" -Driver "c:\test\drivers" -Recurse

Let's modify it slightly: The OS which you want to image is offline, and you have access to it. For instance, the hard disk of the system which is now the subject of imaging is physically mounted on this computer and its OS partition is D:. Or, it is already imaged into a VHD file, the VHD file is mounted and the OS partition is now D:. Issue the following command in Windows PowerShell:

Add-WindowsDriver -Path "D:\" -Driver "c:\test\drivers" -Recurse

To an online OS

Update: Microsoft has pulled off all prose regarding the use of Windows PowerShell to add a driver to a live Windows. So, I went ahead and tried it: It was wrong. Hence, I am updating this answer to introduce a new way.

Having acquired the driver from Microsoft Update Catalog, extract the driver's .cab file. It contains at least one .inf file.

Run InfDefaultInstall.exe to point to their corresponding .inf file. For example, I received a device driver that had a netmosu.inf. So, I changed to its folder and run:

InfDefaultInstall.exe .\netmosu.inf

On Windows 8.1 and 10, this installs the driver even if device is not present and the driver is not needed. Now, you add the device any time you want and just use it. On Windows 7, this does not work.

Update a live system, before imaging it

The techniques above is about updating an OS image either during imaging, after imaging or after deployment of the image when the OS goes live. Why not before all this?

A well-known technique is to install Windows on a system, update everything on it (including all drivers) and then run sysprep utility on it. The hard disk of this computer can now be imaged and deployed to similar systems.

Share:
8,813

Related videos on Youtube

Canadian Luke
Author by

Canadian Luke

Updated on September 18, 2022

Comments

  • Canadian Luke
    Canadian Luke over 1 year

    I am working on re-imaging some older machines. The process is down to a science, and the latest drivers from the manufacturer are injected after the imaging, automatically. I'm happy with this process!

    However, on certain models, the Touchpad driver needs to be updated from Windows Update to prevent an error message from popping up for users. I can manually go into Device Manager, expand Pointing Devices, right-click the Touchpad, and choose Update Driver. It finds the driver online, installs it, then reboots. Error message gone!

    However, I have lots of these systems, and I do not want to do more clicking that necessary. I have the means to deploy Powershell or CMD commands remotely, and I'd like to find a way to get the latest driver for the particular hardware device from Windows Update, automatically.

    • Run5k
      Run5k about 6 years
      At the risk of asking the most obvious question, wouldn't it be ideal to simply integrate the driver into your master image before you deploy it?
    • Canadian Luke
      Canadian Luke about 6 years
      @Run5k I have to support about 40 models. It's easier having the "latest" Dell drivers injected during the imaging process, instead of making a large super-image. My image is minimal this way, so imaging is quick.
    • Run5k
      Run5k about 6 years
      In my experience, when you do support a large number of machines it is beneficial to have a comprehensive master image. The small amount of additional time it takes to deploy our image still saves our team a lot of effort compared to fine-tuning the workstations in person after Windows is installed. Regardless, hopefully someone else can chime in with a good recommendation.