You can try something like this:
$props =
"AllowComputerToTurnOffDevice",
"D0PacketCoalescing",
"DeviceSleepOnDisconnect",
"ArpOffload",
"NSOffload",
"RsnRekeyOffload",
"SelectiveSuspend",
"WakeOnMagicPacket",
"WakeOnPattern"
Get-NetAdapter |
ForEach-Object {
$desc = $_.InterfaceDescription
$name = $_.Name
Get-NetAdapterPowerManagement -Name $name |
ForEach-Object{
$h = [ordered]@{ InterfaceDescription = $desc
Name = $name
}
ForEach ($prop in $props){
$h[$prop] = "" # you need ALL properties in order to produce output that makes sense
# This has to do with the way objects are displayed (or exported)
# => the first objects properties will determine the properties
# displayed for all subsequent objects!
if ($_.$prop -ne "Unsupported"){
$h.$prop = $_.$prop
}
}
[PSCustomObject]$h
}
}
OR, if you want only a simple tabulation:
$props =
"AllowComputerToTurnOffDevice",
"D0PacketCoalescing",
"DeviceSleepOnDisconnect",
"ArpOffload",
"NSOffload",
"RsnRekeyOffload",
"SelectiveSuspend",
"WakeOnMagicPacket",
"WakeOnPattern"
Get-NetAdapter |
ForEach-Object {
$desc = $_.InterfaceDescription
$name = $_.Name
Get-NetAdapterPowerManagement -Name $name | #-InterfaceDescription $_.InterfaceDescription |
ForEach-Object{
$name
$desc
ForEach ($prop in $props){
if ($_.$prop -ne "Unsupported"){
"`t$prop"
}
}
"==============================================="
}
}