Page 1 of 2

Displaying and Interacting with Drivers

Posted: Wed Mar 20, 2019 9:47 am
by JohnTitor
Hello,

I'm looking for a way to manage drives remotely for the techs

Essentially query the PC, list the drivers, give them easy selections USB, DisplayDrivers, Mouse, etc... remotely remove
Think Device Uninstall in device management but not remove the software

I can't seem the find the best solution that provides me with the cleanest details
for example
when I do

Get-CimInstance win32_PnPSignedDriver | Select-Object Description,DeviceClass,DriverProviderName,DriverVersion,FriendlyName,InfName,Manufacturer | Where-Object {$_.Description -ne $null}

But how do I take the InfName, and perform the Device Uninstall?

Re: Displaying and Interacting with Drivers

Posted: Wed Mar 20, 2019 10:13 am
by jvierra
You can only display installed drivers. There is a folder under windows that contains inf files for drivers that are available for installation. You would have to learn how to read these files. They contain manufacturer model and options for a driver along with the driver binaries list.

The folder is here: C:\Windows\INF

Re: Displaying and Interacting with Drivers

Posted: Wed Mar 20, 2019 10:19 am
by jvierra
Here is what a driver INF looks like. This is the USB print driver file.

Code: Select all

[Version]
Signature="$WINDOWS NT$"
Class=USB
ClassGUID={36FC9E60-C465-11CF-8056-444553540000}
Provider=%MSFT%
DriverVer = 06/21/2006,10.0.17763.1

[SourceDisksNames]
3426=windows cd

[SourceDisksFiles]
usbprint.sys = 3426

[ControlFlags]
ExcludeFromSelect = *

[DestinationDirs]
DefaultDestDir = 12
; don't need this yet. USBPRINT_Inst.CopyFilesDLL.NT = 11

[Manufacturer]
%MSFT%=Microsoft,NTamd64

[Microsoft.NTamd64]
%USBPRINT.DeviceDesc% = USBPRINT_Inst,USB\Class_07,GENERIC_USB_PRINTER
%USBPRINT_UNKNOWNPRINTER.DeviceDesc% = NO_DRV, USBPRINT\UnknownPrinter

;=====================================================================
[USBPRINT_Inst.NT]
Copyfiles = USBPRINT_Inst.CopyFiles.NT, USBPRINT_Inst.CopyFilesDLL.NT

[USBPRINT_Inst.CopyFiles.NT]
usbprint.sys,,,0x100

[USBPRINT_INST.CopyFilesDLL.NT]

[USBPRINT_Inst.NT.Services]
AddService = usbprint,0x00000002,USBPRINT_Service_Inst
;=====================================================================

[USBPRINT_Service_Inst]
DisplayName = %USBPRINT.SvcDesc%
ServiceType = 1 ;KERNEL_DRIVER
StartType = 3 ;DEMAND START
ErrorControl = 1 ;RROR_NORMAL
ServiceBinary = %12%\usbprint.sys
LoadOrderGroup = extended base

;SPSVCINST_TAGTOFRONT = 0x00000001
;SPSVCINST_ASSOCSERVICE= 0x00000002
;SERVICE_KERNEL_DRIVER = 1
;SERVICE_BOOT_START = 0
;SERVICE_SYSTEM_START = 1
;SERVICE_AUTO_START = 2
;SERVICE_DEMAND_START = 3
;SERVICE_ERROR_NORMAL = 1
;SERVICE_ERROR_IGNORE = 0


[NO_DRV.NT]

[NO_DRV.NT.Services]
AddService = , 2 ; null service install


[Strings]
;Non-Localizable
MSFT = "Microsoft"

;Localizable
USBPRINT.DeviceDesc = "USB Printing Support"
USBPRINT_UNKNOWNPRINTER.DeviceDesc = "No Printer Attached"
USBPRINT.SvcDesc = "Microsoft USB PRINTER Class"

Re: Displaying and Interacting with Drivers

Posted: Wed Mar 20, 2019 10:27 am
by jvierra
You cannot easily mange devices remotely. The closest you can come is with the PNP WMI classes.

Win32_PnPDevice
Win32_PnPEntity
Win32_PnPSignedDriver
Win32_PnPDeviceProperty


Also:
Get-WmiObject -list WIn32_PnP*

Re: Displaying and Interacting with Drivers

Posted: Wed Mar 20, 2019 10:32 am
by jvierra
Also review the following:

Get-WmiObject -list Win32_Systemd*

Note that these classes only work with installed drivers and devices. THey cannot discover uninstalled drivers and devices like we see in DeviceManager. The DM APIs can be found in the Windows Hardware Dev Center .

Re: Displaying and Interacting with Drivers

Posted: Wed Mar 20, 2019 10:50 am
by jvierra
Here is one thing I just thought of. FOr PnP devices that have been plugged in and have not automatically been installed we can find them like this:

Code: Select all

Get-WmiObject Win32_PNPEntity | 
      Where-Object{$_.ConfigManagerErrorCode -ne 0} | 
      Select Name, DeviceID, ConfigManagerErrorCode
The error codes are here: https://support.microsoft.com/en-us/hel ... in-windows

Re: Displaying and Interacting with Drivers

Posted: Wed Mar 20, 2019 3:11 pm
by JohnTitor
The way we do it in our environment say we want to remove the display driver

Go to device management
Find the display adapter
Right click and choose uninstall
We make sure that “delete associated software” is uncheck
And reboot the machine
Upon logging in, Windows finds the device and installs it.

That’s what I’m looking to do.

Re: Displaying and Interacting with Drivers

Posted: Wed Mar 20, 2019 3:38 pm
by jvierra
Can't do that with PowerShell.

You can remove th device with WMI. Get the device and remove it.

Re: Displaying and Interacting with Drivers

Posted: Wed Mar 20, 2019 3:56 pm
by JohnTitor
Sweet. I’ll look into that and post back.

Re: Displaying and Interacting with Drivers

Posted: Wed Mar 20, 2019 10:15 pm
by JohnTitor
After some more time researching I’ve discovered MS isn’t letting us do this without devcon