We have a fixlet to disable the NIC option “Allow the computer to turn off this device to save power”. The relevance is failing with error “Error: Singular expression refers to non-unique object.”
We have multiple NICs on most of these servers. How do we get fix the relevance so it’s succeeds if there’s a single adapter or multiple and comes back true whether one NIC or multiple are set to Enabled?
(exists “PnPCapabilities” of ((it) of keys of (key “HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class{4D36E972-E325-11CE-BFC1-08002bE10318}” of registry))) AND (exists values “PnPCapabilities” of ((it) of keys of (key “HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class{4D36E972-E325-11CE-BFC1-08002bE10318}” of registry))) AND (value “PnPCapabilities” of ((it) of keys of (key “HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class{4D36E972-E325-11CE-BFC1-08002bE10318}” of registry))) != 280
(disjunction of ((exists “PnPCapabilities” of ((it) of keys of (key “HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class{4D36E972-E325-11CE-BFC1-08002bE10318}” of registry))); (exists values “PnPCapabilities” of ((it) of keys of (key “HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class{4D36E972-E325-11CE-BFC1-08002bE10318}” of registry))); (value “PnPCapabilities” of ((it) of keys of (key “HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class{4D36E972-E325-11CE-BFC1-08002bE10318}” of registry))) != 280))
This part at the beginning isn’t doing what you think…it’s checking whether the string “PnPCapabilities” exists, not whether a value of that name exists (so this part is always True if the key exists regardless of whether the value exists in it)
This part also may not be what you expect - PnPCapabilities is a bitmapped value. I think power saving is only one (or maybe two) of those bits, while the rest of the bits reflect other capabilities (like maybe hot-swappable PCI slots or USB interfaces, etc). So you probably need to identify which bits are involved in power saving mode and just compare those bits .
Adapter with PnPCapabilities not present or set to 0:
Adapter with PnPCapabilities set to decimal 16:
Adapter with PnPCapabilties set to decimal 24:
Adapter with PnPCapabilities set to decimal 256:
From the article:
You have three options for the power management properties of the Network Card:
Option 1: Allow the computer to turn off this device to save power
Option 2: Allow this device to wake the computer
Option 3: Only allow a magic packet to wake the computer
The different possible combinations that exist along with their DWORD values (in decimal and hex) are:
Option 1 and option 2 are checked, Option 3 is unchecked: This combination is default and hence its value is 0.
Option 1, option 2, and option 3 are all checked: The value becomes 0x100 (256).
Only option 1 is checked: The value becomes 0x110 (272).
Option 1 is unchecked (Note that option 2 and option 3 will be greyed out as a result): The value becomes 0x118 (280).
I don’t think 280 is an expected state? But it’s not really clear to me from the article.
In any case, if you’re sure you want to find a 280 in there, I think this query can be a bit simplified
q: exists values "PnPCapabilities" whose (it as integer != 280) of keys of keys "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}" of registry
I’m looking for ANY, not ALL, with option 1 unchecked. I didn’t create that relevance, I was just asked to see why it’s not working. I believe they took that from some built in relevance.
This worked perfectly. If ANY adapter has that option checked it will have a something other than 280 and will be relevant. If it’s 280 then it’s false and not relevant.
exists values “PnPCapabilities” whose (it as integer != 280) of keys of keys “HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class{4D36E972-E325-11CE-BFC1-08002bE10318}” of registry
I want to add another condition without breaking this. You can see in the image below there are several keys with the same GUID name ending in 318. How do we filter out so only if this GUID has class = net?
So I want that added before this.
exists values “PnPCapabilities” whose (it as integer != 280) of keys of keys “HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class{4D36E972-E325-11CE-BFC1-08002bE10318}” of registry
What is the best way to go about that? Use IF statement or two conditions with AND?
Good catch, I completely missed that. I looked at the action script, which was create a couple years ago by someone else, and the problem is that they created it wrong. It’s doing REG_SZ instead of DWORD.