Dealing with Information about power management setting on a network adapter, I created a loop that adds a key to disable windows from cutting power to NIC cards.
for($i=0; $i -le 20; $i++)
{
New-Item -Path ("REGISTRY::HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\" + "{0:0000}" -f $i) -Name "PnPCapabilities" -Value "24"
}
Initially it returns
Hive: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class{4D36E972-E325-11CE-BFC1-08002bE10318}\0000
Name Property
---- --------
PnPCapabilities (default) : 24
So it appears to work, but when I enter regedit, I can not see the key.
Running: Get-Itemproperty -path 'REGISTRY::HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\0001\'
Also returns without the key I added. Though, running the loop again it returns with:
New-Item : A key in this path already exists. At line:3 char:5 + New-Item -Path ("REGISTRY::HKEY_LOCAL_MACHINE\SYSTEM\CurrentContr ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : ResourceExists: (Microsoft.Power...RegistryWrapper:RegistryWrapper) [New-Item], IOException + FullyQualifiedErrorId : System.IO.IOException,Microsoft.PowerShell.Commands.NewItemCommand
So I'm not exactly sure why I cant see the key I created. I'm on Windows 10 pro, if that makes a difference.
"{0:0000}" -f $i)
should be("{0:0000}" -f $i)
. You're missing the opening bracket. - Theo