Change a driver via Powershell or CMD

Stephenie Siegmann EDA 5 Reputation points

I have two device drivers to choose for the camera.

in the UI I go:

Device Manager -> Device -> Update Drivers -> Browse my computer for driver software -> Let me pick from a list of available drivers on my computer -> Select one of two available drivers.

While the Driver from the Notebook Manufacturer is not working correctly for some models I need to switch back to the Microsoft Standard Driver (usbvideo.inf) that is already installed on the system.

While changing this in the devicemanager works fine, with PNPUTIL it does not.

What we have is this:

$Cameras = Get-WmiObject Win32_PnPSignedDriver | Where-Object { $_.FriendlyName -eq "HP IR Camera" -or $_.FriendlyName -eq "HP HD Camera" }
		If ($cameras -eq 0) {
			$Cameras = Get-WmiObject Win32_PnPSignedDriver | Where-Object { $_.DeviceClass -eq "Camera" -and $_.Devicename -eq "HP IR Camera" -or $_.DeviceName -eq "HP HD Camera" }
			$NewDriverPath = (Get-WindowsDriver -Online -All | Where-Object Driver -eq "usbvideo.inf").OriginalFileName

			foreach ($Camera in $Cameras) {
			if ($Camera.InfName -ne "usbvideo.inf") {
				Write-Host "Driver is getting updated"

				# Retrieving the associated driver package
				$CurrentDriver = Get-WindowsDriver -Online -All | Where-Object Driver -eq $Camera.InfName

				# Uninstalling current driver
				pnputil.exe /delete-driver $CurrentDriver.OriginalFileName /uninstall

				# Installing new driver
				pnputil.exe /add-driver $NewDriverPath /install
				} else {
				Write-Host "Driver is already updated"

For some this works, but sometimes this leaves the device in an unknown state without any driver and then it is forked. There seems to be no way that I can go via PNPUTIL and tell it that it should install the usbvideo.inf for

DeviceID : USB\VID_04F2&PID_B6BF&MI_02\6&1737142C&0&0002

So I have to login with my admin account to klick update driver in Devicemanager.

If anyone could help out with a good idea how this can be done I would appreciate this very much.



A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,290 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Limitless Technology 44,096 Reputation points


    I'd be happy to help you out with your question. Sorry for the inconvenience caused.

    Here are the steps on how to change a driver via PowerShell or CMD:

    1. Open PowerShell or CMD as an administrator.
    2. Run the following command to get the device ID of the camera:

    pnputil /enum-devices

    1. Look for the device ID that corresponds to the camera. In your case, the device ID is USB\VID_04F2&PID_B6BF&MI_02\6&1737142C&0&0002.
    2. Run the following command to install the usbvideo.inf driver for the camera:

    pnputil /add-driver "C:\Windows\System32\DriverStore\FileRepository\usbvideo.inf" /install /driverid "USB\VID_04F2&PID_B6BF&MI_02\6&1737142C&0&0002"

    1. Restart your computer.

    Once you have completed these steps, the camera should be using the usbvideo.inf driver.

    Here are some additional things to keep in mind:

    • You may need to download the usbvideo.inf driver from the manufacturer's website.
    • If you are not sure how to find the device ID of the camera, you can use the Device Manager to find it.
    • If you are still having problems after following these steps, you may need to contact the manufacturer of the camera for support.

    For more Information, please refer to following resource :-

    Set-CMDriver (ConfigurationManager) -

    If you have any other questions or need assistance with anything, please don't hesitate to let me know. I'm here to help.

    If the reply was helpful, please don’t forget to upvote or accept as answer, thank you.