I am trying to recursively search a directory, find any .inf files within and pass those files to pnputil to add those drivers to windows drivers directory.
I have the following:
cd /drivers
$x = ls -Path . -Filter "*.inf" -Recurse -ErrorAction SilentlyContinue
Foreach ($i in $x){
pnputil /a $i
}
and I get the following error from pnputil:
Adding the driver package failed : Invalid INF passed as parameter.
I am assuming it's failing because pnputil doesn't like the object it's getting. Any suggestion as to what to pass it, or what to modify?
Thank you!
You knew what the issue was. You are passing an object to the command line. What you need to do is extract the full path from that
System.IO.FileInfo
object to pass topnputil
That should get you the results you are looking for. Another thing you could have done was change
$x
so that it was an array of file names.-ExpandProperty
being the important part.