5

Are we able to install drivers via their .inf files etc. using a PowerShell cmdlet? When Googling I found, Add-WindowsDriver but I think this one is for an offline Windows image. Does that mean an image that is not currently used on an OS? If not, please teach me how to write the parameters. Thank you!

DrixlRey
  • 205
  • 3
  • 4
  • 13
  • 1
    `Start-Process -Path $PathToInf -Verb Install`? – Bacon Bits Oct 21 '16 at 15:02
  • I just realize you can right click install .inf files, however, this .inf file says "The INF file you selected does not support this method of installation." – DrixlRey Oct 21 '16 at 15:31
  • 1
    How about using PNPUTIL? For example: `pnputil.exe -i -a C:\example\example.INF` – BenH Oct 21 '16 at 17:25
  • Hi Benh, it gave me an error `Failed to install: No more data is available` I believe this is because the device already has an existing driver, I need to install these new drivers I have, how would I tell PS or CMD specifically to replace the existing drivers with this new one? – DrixlRey Oct 21 '16 at 18:47
  • 2
    You'll need to delete the old one first. So you'll need to enumerate all of the current drivers with `pnputil.exe -e` then find what it's named and then `pnputil.exe -f -d oem0.inf` (-f is force and may not be needed) – BenH Oct 21 '16 at 19:23

3 Answers3

10

This PowerShell script will do what you want:

Get-ChildItem "C:\Driver File Location" -Recurse -Filter "*inf" | ForEach-Object { PNPUtil.exe /add-driver $_.FullName /install } 
Paul Roub
  • 36,322
  • 27
  • 84
  • 93
Jeffery Allen
  • 116
  • 2
  • 5
2

You don't need Powershell or advanced CMD programming, because pnputil.exe has a /subdirs command line switch and can slurp multiple .inf files at once. On my system (Windows 10 x64 21H2), you can simply execute:

pnputil /add-driver *.inf /install /subdirs

That does what I would expect.

pnputil.exe's help tells everything we need. Just execute pnputil without further parameters, and it outputs an understandable help screen (that is too long to post it here).

Binarus
  • 4,005
  • 3
  • 25
  • 41
-1

It can be done using the Install-DeviceDriver cmdlet from the DeviceManagement module. See my answer here for an example.

Jakub Berezanski
  • 1,053
  • 9
  • 13