Question

How do I create a worklet to Enable USB Ports?

  • 20 March 2023
  • 0 replies
  • 63 views

Badge

Hi everyone,

I'm currently using the following PowerShell script to disable USB storage devices and enable mouse and keyboard devices:

# Disable USB storage devices
$usbDevices = Get-PnpDevice -Class "USB" -Status OK | Where-Object {$_.Service -eq "USBSTOR"}
foreach ($usbDevice in $usbDevices) {
Disable-PnpDevice -InstanceId $usbDevice.InstanceId -Confirm:$false
}

# Enable mouse and keyboard devices
$mouseDevice = Get-PnpDevice -Class "Mouse" -Status OK | Where-Object {$_.ConfigManagerErrorCode -eq 0}
$keyboardDevice = Get-PnpDevice -Class "Keyboard" -Status OK | Where-Object {$_.ConfigManagerErrorCode -eq 0}
Enable-PnpDevice -InstanceId $mouseDevice.InstanceId -Confirm:$false
Enable-PnpDevice -InstanceId $keyboardDevice.InstanceId -Confirm:$false

# Evaluation code
Write-Output "This code disables USB storage devices and enables mouse and keyboard devices."

However, I need to find an Automox worklet that enables USB drives. Can anyone help me find a worklet that does this?


0 replies

Be the first to reply!

Reply