Disable-PnpDevice while device is used?

1

I have a webcam which i want to deactive via powershell script. I have the following line:

Get-PnpDevice -FriendlyName 'USB-Videogerät' -Class Camera | Disable-PnpDevice -Confirm:$false

But it only works when no program uses the webcam. Is it even possible to deactive a device even though its used by discord or another program?

Disable-PnpDevice : Allgemeiner Fehler
In C:\Users\Nico\Desktop\Scripts\Webcam\WEBCAM_OFF.ps1:10 Zeichen:72
+ ... me 'USB-Videogerät' -Class Camera | Disable-PnpDevice -Confirm:$false
+                                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (Win32_PnPEntity...A&62E8ABC&0...):ROOT\cimv2\Win32_PnPEntity) [Disable-Pn
   pDevice], CimException
    + FullyQualifiedErrorId : HRESULT 0x80041001,Disable-PnpDevice
powershell
asked on Stack Overflow May 13, 2021 by Nico1300 • edited May 13, 2021 by Nico1300

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0