Windows configuration
Check Power & Sleep Settings
Reports the current power and sleep configuration.
Replace generic placeholder values (tenant, domain, secrets) for your own environment before running. Read it first and test safely.
# Power Settings Report Script
# Run as SYSTEM
# 64-bit PowerShell
$ErrorActionPreference = 'Stop'
# GUIDs
$SubVideoGuid = '7516b95f-f776-4464-8c53-06167f40cc99'
$VideoIdleGuid = '3c0bc021-c8a8-4e07-a973-6b14cbcb2b7e'
$SubSleepGuid = '238c9fa8-0aad-41ed-83f4-97be242c8f20'
$StandbyIdleGuid = '29f6c1db-86da-48c5-9fdb-f2b67b1f44da'
$HibernateIdleGuid = '9d7815a6-7ee4-497e-8888-515a05f02364'
function Get-ActiveScheme {
$out = powercfg /getactivescheme
return ([regex]::Match($out, '[a-f0-9\-]{36}')).Value
}
function Get-Setting {
param($Scheme, $Sub, $Setting)
$out = powercfg /query $Scheme $Sub $Setting
$ac = ([regex]::Match($out, 'AC Power Setting Index:\s*0x([0-9a-fA-F]+)')).Groups[1].Value
$dc = ([regex]::Match($out, 'DC Power Setting Index:\s*0x([0-9a-fA-F]+)')).Groups[1].Value
return @{
AC = [convert]::ToInt32($ac, 16)
DC = [convert]::ToInt32($dc, 16)
}
}
function Format-Time($seconds) {
if ($seconds -eq 0) {
return "Never"
}
$minutes = $seconds / 60
if ($minutes -lt 60) {
$roundedMinutes = [math]::Round($minutes, 0)
if ($roundedMinutes -eq 1) {
return "1 minute"
}
return "$roundedMinutes minutes"
}
$hours = $minutes / 60
$roundedHours = [math]::Round($hours, 2)
if ($roundedHours -eq 1) {
return "1 hour"
}
return "$roundedHours hours"
}
# Power mode API
Add-Type @"
using System;
using System.Runtime.InteropServices;
public class PMode {
[DllImport("powrprof.dll")] public static extern UInt32 PowerGetUserConfiguredACPowerMode(out Guid g);
[DllImport("powrprof.dll")] public static extern UInt32 PowerGetUserConfiguredDCPowerMode(out Guid g);
}
"@
function TranslateMode($g) {
switch ($g) {
"ded574b5-45a0-4f42-8737-46345c09c238" { "Best Performance" }
"00000000-0000-0000-0000-000000000000" { "Balanced" }
"961cc777-2547-4f9d-8174-7d86181b8a7a" { "Best Power Efficiency" }
default { "Unknown" }
}
}
$scheme = Get-ActiveScheme
$display = Get-Setting $scheme $SubVideoGuid $VideoIdleGuid
$sleep = Get-Setting $scheme $SubSleepGuid $StandbyIdleGuid
$hiber = Get-Setting $scheme $SubSleepGuid $HibernateIdleGuid
$acMode = [guid]::Empty
$dcMode = [guid]::Empty
[PMode]::PowerGetUserConfiguredACPowerMode([ref]$acMode) | Out-Null
[PMode]::PowerGetUserConfiguredDCPowerMode([ref]$dcMode) | Out-Null
$acModeName = TranslateMode $acMode.Guid
$dcModeName = TranslateMode $dcMode.Guid
Write-Output ""
Write-Output "Power Settings Report"
Write-Output "--------------------------------"
Write-Output ""
Write-Output "Plugged In"
Write-Output "Screen Off: $(Format-Time $display.AC)"
Write-Output "Sleep: $(Format-Time $sleep.AC)"
Write-Output "Hibernate: $(Format-Time $hiber.AC)"
Write-Output "Power Mode: $acModeName"
Write-Output ""
Write-Output "On Battery"
Write-Output "Screen Off: $(Format-Time $display.DC)"
Write-Output "Sleep: $(Format-Time $sleep.DC)"
Write-Output "Hibernate: $(Format-Time $hiber.DC)"
Write-Output "Power Mode: $dcModeName"
Write-Output ""
Write-Output "--------------------------------"