Shridhar
Shridhar

Reputation: 1

Uninstall hidden “Network Adapters” from Device Manager using PowerShell script

Query: Uninstall hidden “Network Adapters” from Device Manager using PowerShell script
Operating System: Windows 10

Steps:

  1. Open Device Manager from Control Panel
  2. Select “Show hidden devices” from View menu
  3. Expand “Network adapters”
  4. Find hidden adapters

Manually these hidden adapters can be uninstall by below steps

  1. Right click on hidden adapter
  2. Click on uninstall.
  3. Click on Ok button.

How to uninstall these adapters using PowerShell script?

$Devs = Get-PnpDevice -Class net |
        ? Status -eq Unknown |
        Select FriendlyName, InstanceId

foreach ($Dev in $Devs) {
    Write-Host "Removing $($Dev.FriendlyName)" -ForegroundColor Cyan
    $RemoveKey = "HKLM:\SYSTEM\CurrentControlSet\Enum\$($Dev.InstanceId)"
    Get-Item $RemoveKey |
        Select-Object -ExpandProperty Property |
        %{ Remove-ItemProperty -Path $RemoveKey -Name $_ -Verbose }
}
Write-Host "Done.  Please restart!" -ForegroundColor Green

This code throws an error:

Remove-ItemProperty : Requested registry access is not allowed.

Upvotes: 0

Views: 4209

Answers (1)

Ansgar Wiechers
Ansgar Wiechers

Reputation: 200483

The user running the script does not have permission to delete the particular key from the registry. Either fix the permissions or run with a user that does have the required permissions.

If you're already running the script with an admin user you may still need to run it from an elevated console (due to UAC) or make the script self-elevating. However, there are some places in the registry that even admins don't have access to by default. If the key you want to delete is one of those you need to change its permissions first (and probably the permissions of its parent key too).

Upvotes: 1

Related Questions