Advertisement
guyrleech

Show devices which are power managed

Jul 14th, 2020
540
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ## Put PnP device ids into a hashtable (dictionary) for fast lookup of friendly names
  2. [hashtable]$devices=@{} ; Get-PnpDevice|ForEach-Object{ $devices.Add( $_.InstanceId  , $_.FriendlyName ) }
  3.  
  4. Get-CimInstance -ClassName MSPower_DeviceEnable -Namespace root\wmi | Select-Object -Property @{name='FriendlyName';expression={$devices[ $_.InstanceName -replace '_\d+$' ]}}, Active,Enable,InstanceName | Sort-Object -Property FriendlyName
  5.  
  6. ## Optionally change Power Management state by changing "Enable" property of the object(s) returned from Get-CimInstance and pipe through Set-CimInstance
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement