Uninstall Device from powershell

纵饮孤独 提交于 2021-02-20 05:12:33

问题


I run automation that installs a preset OS /w Drivers and configuration. I inherited the automation second hand and there's a lot to it. I have a system with hybrid graphics and it hands on verifying the display drivers. Now, I can walk over to the machine, open device manager, right click on one of the graphics devices, click uninstall (i do not delete the driver files) and then the automation continues. Once its done, the system restarts and both device drivers are back. I am wondering if there is a powershell command i can run to do the same task through automation?

what do you guys think!


回答1:


You can do this using WMI instance:

get-wmiobject -Query "select * from win32_systemdriver where caption=`"THING_TO_REMOVE`"" } | ForEach  { $_.StopService()
$_.Delete()
 } 



回答2:


It's not powershell, but I've always used the command line version of device manager called devcon: https://docs.microsoft.com/en-us/windows-hardware/drivers/devtest/devcon



来源:https://stackoverflow.com/questions/60638900/uninstall-device-from-powershell

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!