0

I want to remove called "vmxnet3 network adapter".

Get-PnpDevice -FriendlyName "vmxnet3 Ethernet Adapter"

AFAIK , Pnputil doesn't support the uninstall of devices, only drivers.

Steps:

Open Device Manager from Control Panel
Select “Show hidden devices” from View menu
Expand “Network adapters”
vmxnet3 network adapter

Right click on  adapter
Click on uninstall.
Click on Ok button.

Do not check "Delete the driver software for this device"

How to uninstall these adapters using PowerShell script?

script :

get-wmiobject -Query "select * from win32_systemdriver where caption=`"vmxnet3 NDIS 6 Ethernet Adapter Driver`""  | ForEach  { $_.StopService()
$_.Delete()
 } 

output:

__GENUS          : 2
__CLASS          : __PARAMETERS
__SUPERCLASS     :
__DYNASTY        : __PARAMETERS
__RELPATH        :
__PROPERTY_COUNT : 1
__DERIVATION     : {}
__SERVER         :
__NAMESPACE      :
__PATH           :
ReturnValue      : 4
PSComputerName   :

__GENUS          : 2
__CLASS          : __PARAMETERS
__SUPERCLASS     :
__DYNASTY        : __PARAMETERS
__RELPATH        :
__PROPERTY_COUNT : 1
__DERIVATION     : {}
__SERVER         :
__NAMESPACE      :
__PATH           :
ReturnValue      : 0
PSComputerName   :

thanks,

Arbelac
  • 1,698
  • 6
  • 37
  • 90
  • Are you saying, that you've searched all of SO, the Web, and Youtube, and that you could not find anything relevant to your use case? [powershell 'uninstall device without delete driver'](https://duckduckgo.com/?q=powershell+%27uninstall+device+without+delete+driver%27&t=h_&ia=web) --- Did you look into Windows UI Automation and or Selenium UI automation tools? – postanote Nov 26 '22 at 19:47
  • I don't want to use any automation tools. I will do Get-WmiObject. but no luck. I've updated my question. – Arbelac Nov 26 '22 at 19:51
  • Wouldn't plug n play just install it again? – js2010 Nov 26 '22 at 20:30

1 Answers1

0

As per the list in my comment.

powershell 'uninstall device without delete driver'

  • The 3rd item in the ist

https://social.msdn.microsoft.com/Forums/security/en-US/7834d3e9-80b7-4d6e-a76f-b6d44c7ed36b/remove-driver-with-powershell?forum=wdk

Drivers are designed to be deleted by WMI or the driver manager. It is a Windows Logo requirement.

Deleting the driver does not delete the files it just deletes the keys and connections between the OS and the driver. Remember that drivers are installed from "inf" files stored in the system folder. All drivers must reside there before then can be installed. Drivers are owned by Windows. They are not owned by the vendor. The vendor merely supplies a file that follows the OS rules for accessing the device. The vendor may supply other files to support specific software. In the case of adapter drivers, it is just glue between Windows and the adapter. Many adapters come with sophisticated utilities to monitor and manage the adapter. These are unnecessary outside of their utility. If the driver is removed they won't work but they will not cause an issue either.

First, disable the driver then delete it. As long as it is loaded you cannot delete it.

$x=Get-WmiObject Win32_PnPSignedDriver -filter "DeviceName='AMD Radeon HD 7570'"
$x.delete()
  • 4th item in the list.

How to Uninstall a Device with Powershell

I found how to remove the Driver package on the computer, so this way once I can uninstall the keyboard it won't reinstall with that driver, but take the default PS2 drivers.

$oemfiles = Get-ChildItem c:\windows\inf\oem*.inf
foreach($file in $oemfiles){
    if(get-content $file | select-string -pattern 'hpkeyboard' -SimpleMatch)
        {PnPUtil /Delete-Driver $file.name /force }
}
postanote
  • 15,138
  • 2
  • 14
  • 25
  • thanks man but , I will remove only uninstall (i do not delete the driver files). Btw I have tried your command (Win32_PnPSignedDriver ). But I am getting an error message like below `Exception calling "Delete" with "0" argument(s): "Operation is not valid due to the current state of the object." At line:1 char:1 + $x.delete() + ~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : DotNetMethodException ` – Arbelac Nov 26 '22 at 20:06
  • Remember the additional step from the provided link: ***First, disable the driver then delete it. As long as it is loaded you cannot delete it.***. ```Disable-PnpDevice```. – postanote Nov 26 '22 at 20:47
  • Like you said , I've tried it. But still same issue. firstly , I am running `Disable-PnPDevice` cmdlet. then I am trying to uninstall device. same error message. – Arbelac Nov 27 '22 at 08:47