AutomoxAutomox

How do I create a worklet to Enable USB Ports?

dylan
March 20, 2023 at 9:23 pm UTC

Hi everyone,

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

powershell14 lines
# 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?

This discussion is archived and closed to replies. Continue it in the Automox Community Slack.

Discuss on Slack