I'm creating a powershell script template by using my device "Integrated Webcam". There's an issue at work where a touch screen is enabling when its screen is closed with it docked. I have been trying to create said script to make it where it won't do this when you run the script and it will decide to enable or disable the touch screen device via powershell. Thus, bringing me here (Pardon the notes, just documenting for myself):
REM Get-WmiObject Win32_PNPEntity | where {$_.name -like "Integrated Webcam*"}
Import-module .\DeviceManagement.psd1
REM Get-Device | where {$_.name -like "Integrated Webcam*"} | Disable-Device
REM Get-Device | where {$_.name -like "Integrated Webcam*"} | Enable-Device
REM Get-Device | where {$_.name -like "Integrated Webcam*"}
REM ***ConfigurationFlags : CONFIGFLAG_DISABLED ---> Disabled
REM ***ConfigurationFlags : 0 ---> Enabled
REM Variables
$OnStatus = Get-WmiObject Win32_PNPEntity | where {$_.Status -eq "OK"}
$OffStatus = Get-WmiObject Win32_PNPEntity | where {$_.Status -eq "Error"}
$DeviceID = Get-WmiObject Win32_PNPEntity | where {$_.DeviceID -like "USB\VID_0C45&PID_64AD&MI_00\7&342EE79C&0&0000"}
REM Get-WmiObject Win32_PNPEntity | where {$_.Status -like "Error*"}
REM Get-Device ????
REM **Disable Device -- Works**
if
($DeviceID -AND $OnStatus){
Get-Device | where {$_.name -like "Integrated Webcam*"} | Disable-Device
REM **Else doesn't work** **Tried elseif also**
}else{
Get-Device | where {$_.name -like "Integrated Webcam*"} | Enable-Device
}
REM **Enable device -- works **
if ($DeviceID -AND $OffStatus){
Get-Device | where {$_.name -like "Integrated Webcam*"} | Enable-Device
}
Any Suggestions?
Aucun commentaire:
Enregistrer un commentaire