Hola guys,
I created a PowerShell script to block all removable storage devices, which successfully restricted USB access. However, when I tried modifying the script to allow access again, the devices still remained blocked.
Here’s the script I used to block USB access:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
$regPath = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\RemovableStorageDevices" if (-not (Test-Path $regPath)) { New-Item -Path $regPath -Force } Set-ItemProperty -Path $regPath -Name "Deny_All" -Value 1 -Type DWord $usbClassGUID = "{36fc9e60-c465-11cf-8056-444553540000}" $usbPath = "$regPath\$usbClassGUID" if (-not (Test-Path $usbPath)) { New-Item -Path $usbPath -Force } Set-ItemProperty -Path $usbPath -Name "Deny_Read" -Value 1 -Type DWord Set-ItemProperty -Path $usbPath -Name "Deny_Write" -Value 1 -Type DWord Write-Output "Removable media access has been blocked." |
The issue is that even after removing these registry keys, the restrictions seem to persist, and the keys reappear after a while. I’m looking for a way to regain access to USB through a script. Has anyone faced this before or knows how to fix it?
Any help would be appreciated!