Skip to content
Menu

USB Storage Not Blocked - Check the Block Policy

Checks whether USB mass storage is blocked by the drivers, the removable-storage policy or the device-installation policy, and lists disks recorded in USBSTOR.

USB storage not blocked - check the block policy is free for members.

Enter your email to create your free account and get the file.

We'll email you the script and the weekly MSP Outpost email. Unsubscribe anytime. Privacy policy.

Already a member? Sign in.

Be the first to review USB storage not blocked - check the block policy. Tell other MSPs how it worked for you.

Write a Review

LanguagePowerShell
Runs onWindows 10, Windows 11, Windows Server 2016+; runs as SYSTEM
NeedsPowerShell 5.1
Read-onlyReads, changes nothing

What It Does

The script is read-only. It decides whether USB mass storage is blocked, by any of three mechanisms: the USB storage drivers disabled, with the USBSTOR service Start set to 4 and UASPStor Start set to 4 where that driver exists, because USB 3 drives that use UASP bypass USBSTOR; the removable-storage policy denying access, with Deny_All, or Deny_Read and Deny_Write on the Removable Disks class; or the device-installation policy denying USB mass storage, with DenyDeviceIDs and DenyDeviceIDsRetroactive set to 1 and USB\Class_08 on the deny list. The script checks only those policy values, not the install policy's exceptions.

With Mode Block, the default, any of those counts as blocked. With Mode ReadOnly a write-deny policy, Deny_Write alone, counts as well. It lists only disk entries in USBSTOR, with their serials and reported connection state. USB CD, DVD and tape devices are excluded. If Windows cannot report which drives are currently connected, the script warns.

AllowedSerials marks devices you approved, in the Allowed column. It does not change whether the PC alerts. A device that is connected now and not allowed while USB storage is blocked is reported as a warning, because a drive already mounted can remain accessible until it is plugged in again or the PC restarts. A USB drive with no serial shows Windows' own made-up instance number.

Before You Run It

  • Use the same Mode as you used with disable-usb-storage.
  • Run it once and read the Serial column. Those values are what you put in AllowedSerials.
  • A drive already connected may remain mounted until it is unplugged or the PC restarts.
  • Use disable-usb-storage to fix what this alerts on.

Type and Risk

  • Type: Monitor. It checks one condition. It exits 1 when it finds the problem, so your RMM can alert on it, 0 when all is well, and 2 when it could not run.
  • Risk: Low. It reads and changes nothing.
  • Restart: It never restarts the machine.
  • Typical run: Under 15 seconds.
  • Example answer: "USB storage is NOT blocked (USBSTOR Start=3, no deny policy); 2 USB storage device(s) seen, 1 connected now"
  • Tested before listing on Windows 11 with Windows PowerShell 5.1, run as SYSTEM, against its own test cases.

Inputs

Pass an input as an argument (-Name value), as an environment variable with the same name, which is how most RMMs pass script variables, or change its default in the param() block at the top of the script. An argument wins over an environment variable, which wins over the default.

  • Mode: Block (default) or ReadOnly. Block: USB storage must be fully blocked. ReadOnly: a write block also passes. Use the same value as disable-usb-storage.
  • AllowedSerials: Serial numbers of USB drives you approved, separated by commas or semicolons (see the Serial column of a first run). Default empty. Matched exactly, ignoring case.

Every script also takes DryRun, OutputFormat (Text, Answer, Json or Csv), ExportPath and ResultField, which writes the answer to an RMM custom field.

License

Provided "as is" under the MIT License, without warranty of any kind. Test before production use. MSP Outpost and User First Digital Inc. accept no liability for any damage or loss.

The Script

test-usb-storage-blocked.ps1 · 886 lines · 45.4 KB

Free for Members

Create a free account or sign in to read, copy and download this script.

Welcome Back

Sign in to your MSP Outpost account.