Last active
December 12, 2025 22:36
-
-
Save kamronbatman/5885af2d0212c33c27d6b62b42e96f57 to your computer and use it in GitHub Desktop.
Configures Dell & Windows Wake-on-LAN Remotely using Powershell
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <# | |
| .SYNOPSIS | |
| Enhanced Wake-on-LAN configuration script for Dell machines. | |
| Configures BIOS and network adapter settings for reliable WOL. | |
| .PARAMETER ComputerName | |
| The target Dell computer's hostname or IP address. | |
| .NOTES | |
| Requires Administrator privileges on both the server running the script and the target client. | |
| CRITICAL: A REBOOT is required after running this script for changes to take effect. | |
| Modern Standby (S0) and power button settings should be configured via GPO. | |
| #> | |
| param( | |
| [Parameter(Mandatory=$true)] | |
| [string]$ComputerName | |
| ) | |
| $BIOSSetting = "LanOnly" | |
| Write-Host "=== Enhanced WOL Configuration for $ComputerName ===" -ForegroundColor Cyan | |
| Write-Host "Configures BIOS and network adapter for reliable Wake-on-LAN" -ForegroundColor Cyan | |
| Write-Host "" | |
| # --- Step 1: Update PowerShellGet --- | |
| try { | |
| Write-Host "[1/3] Updating PowerShellGet on $ComputerName..." -ForegroundColor Yellow | |
| Invoke-Command -ComputerName $ComputerName -ScriptBlock { | |
| Install-Module -Name PowerShellGet -Force -Scope AllUsers -AllowClobber -Repository PSGallery -WarningAction SilentlyContinue | |
| } -ErrorAction Stop | |
| Write-Host "✓ PowerShellGet updated successfully." -ForegroundColor Green | |
| } | |
| catch { | |
| Write-Warning "PowerShellGet update failed (may already be current): $($_.Exception.Message)" | |
| } | |
| # -------------------------------------------------------------------------------------------------- | |
| # --- Step 2: Configure WOL in BIOS --- | |
| try { | |
| Write-Host "[2/3] Configuring BIOS WOL settings..." -ForegroundColor Yellow | |
| Invoke-Command -ComputerName $ComputerName -ScriptBlock { | |
| param([string]$SettingValue) | |
| # Check if DellBIOSProvider is installed | |
| if (-not (Get-Module -ListAvailable -Name DellBIOSProvider)) { | |
| Write-Host "Installing DellBIOSProvider..." | |
| Install-Module -Name DellBIOSProvider -Force -Scope AllUsers -WarningAction SilentlyContinue | |
| } | |
| Import-Module DellBIOSProvider -ErrorAction Stop | |
| # Set Wake on LAN | |
| try { | |
| Set-Item -Path DellSmbios:\PowerManagement\WakeOnLan $SettingValue -ErrorAction Stop | |
| $CurrentWOL = (Get-Item -Path DellSmbios:\PowerManagement\WakeOnLan).CurrentValue | |
| Write-Host "✓ BIOS WOL set to: $CurrentWOL" -ForegroundColor Green | |
| } catch { | |
| Write-Warning "Could not set WakeOnLan: $($_.Exception.Message)" | |
| } | |
| # Disable Deep Sleep Control if available | |
| try { | |
| Set-Item -Path DellSmbios:\PowerManagement\DeepSleepCtrl Disabled -ErrorAction Stop | |
| $DeepSleep = (Get-Item -Path DellSmbios:\PowerManagement\DeepSleepCtrl).CurrentValue | |
| Write-Host "✓ Deep Sleep Control: $DeepSleep" -ForegroundColor Green | |
| } catch { | |
| Write-Host "Deep Sleep Control not available on this model (this is OK)" -ForegroundColor Gray | |
| } | |
| # Disable Block Sleep if available | |
| try { | |
| Set-Item -Path DellSmbios:\PowerManagement\BlockSleep Disabled -ErrorAction Stop | |
| Write-Host "✓ Block Sleep: Disabled" -ForegroundColor Green | |
| } catch { | |
| Write-Host "Block Sleep not available on this model (this is OK)" -ForegroundColor Gray | |
| } | |
| } -ArgumentList $BIOSSetting -ErrorAction Stop | |
| Write-Host "✓ BIOS configuration completed." -ForegroundColor Green | |
| } | |
| catch { | |
| Write-Error "Failed to configure BIOS settings: $($_.Exception.Message)" | |
| Write-Warning "Continuing with network adapter configuration..." | |
| } | |
| # -------------------------------------------------------------------------------------------------- | |
| # --- Step 3: Configure Network Adapter WOL Settings --- | |
| try { | |
| Write-Host "[3/3] Configuring Network Adapter WOL settings..." -ForegroundColor Yellow | |
| Invoke-Command -ComputerName $ComputerName -ScriptBlock { | |
| # Discover the target adapter (first active wired ethernet) | |
| $TargetAdapter = Get-NetAdapter -Physical | Where-Object { | |
| ($_.MediaType -eq "802.3") -and ($_.Status -ne "Disabled") | |
| } | Select-Object -First 1 | |
| if (-not $TargetAdapter) { | |
| throw "No suitable network adapter found!" | |
| } | |
| $Adapter = $TargetAdapter.Name | |
| Write-Host "Configuring adapter: '$Adapter'" -ForegroundColor Cyan | |
| $PnPDeviceID = (Get-NetAdapter -Name $Adapter).PnPDeviceID | |
| $AdapterDescription = (Get-NetAdapter -Name $Adapter).InterfaceDescription | |
| # Detect adapter vendor | |
| $IsIntel = $AdapterDescription -match "Intel" | |
| $IsRealtek = $AdapterDescription -match "Realtek" | |
| Write-Host "Adapter: $AdapterDescription" -ForegroundColor Gray | |
| if ($IsIntel) { | |
| Write-Host "Detected: Intel adapter" -ForegroundColor Gray | |
| } elseif ($IsRealtek) { | |
| Write-Host "Detected: Realtek adapter" -ForegroundColor Gray | |
| } | |
| # --- A. Configure Advanced Properties (with vendor-specific handling) --- | |
| # Common settings for all adapters | |
| $CommonSettings = @{ | |
| "Wake on Magic Packet" = 1 | |
| "Wake on pattern match" = 1 | |
| "Energy Efficient Ethernet" = 0 | |
| } | |
| # Realtek-specific settings | |
| $RealtekSettings = @{ | |
| "Shutdown Wake-on-LAN" = 1 | |
| "WOL & Shutdown Link Speed" = "10 Mbps First" | |
| } | |
| # Intel-specific settings (usually none beyond common) | |
| $IntelSettings = @{ | |
| # Intel adapters typically don't have Realtek-specific properties | |
| # But we'll try them anyway in case | |
| } | |
| # Merge settings based on adapter type | |
| $AdvancedSettings = $CommonSettings.Clone() | |
| if ($IsRealtek) { | |
| foreach ($key in $RealtekSettings.Keys) { | |
| $AdvancedSettings[$key] = $RealtekSettings[$key] | |
| } | |
| } | |
| Write-Host "" | |
| Write-Host "Configuring Advanced Properties..." -ForegroundColor Cyan | |
| foreach ($Key in $AdvancedSettings.Keys) { | |
| try { | |
| $CurrentProp = Get-NetAdapterAdvancedProperty -Name $Adapter -DisplayName $Key -ErrorAction SilentlyContinue | |
| if (-not $CurrentProp) { | |
| Write-Host " '$Key' not available on this adapter" -ForegroundColor Gray | |
| continue | |
| } | |
| # Handle both numeric and string values | |
| $DesiredValue = $AdvancedSettings[$Key] | |
| $CurrentValue = $CurrentProp.RegistryValue | |
| # For string values, compare display values | |
| if ($DesiredValue -is [string] -and $DesiredValue -notmatch '^\d+$') { | |
| if ($CurrentProp.DisplayValue -eq $DesiredValue) { | |
| Write-Host " '$Key' already set correctly: $($CurrentProp.DisplayValue)" -ForegroundColor Gray | |
| continue | |
| } else { | |
| # Try to set using display value | |
| Set-NetAdapterAdvancedProperty -Name $Adapter -DisplayName $Key -DisplayValue $DesiredValue -ErrorAction Stop | |
| Write-Host "✓ Set '$Key' to '$DesiredValue'" -ForegroundColor Green | |
| } | |
| } else { | |
| # Numeric value | |
| if ($CurrentValue -eq $DesiredValue) { | |
| Write-Host " '$Key' already set correctly: $CurrentValue" -ForegroundColor Gray | |
| continue | |
| } else { | |
| Set-NetAdapterAdvancedProperty -Name $Adapter -DisplayName $Key -RegistryValue $DesiredValue -ErrorAction Stop | |
| Write-Host "✓ Set '$Key' to $DesiredValue" -ForegroundColor Green | |
| } | |
| } | |
| } | |
| catch { | |
| Write-Host " '$Key' - Error: $($_.Exception.Message)" -ForegroundColor Yellow | |
| } | |
| } | |
| # --- B. Enable Power Management via Registry (more reliable than WMI) --- | |
| Write-Host "" | |
| Write-Host "Configuring Power Management via Registry..." -ForegroundColor Cyan | |
| # Find the network adapter's registry key | |
| $AdapterGuid = (Get-NetAdapter -Name $Adapter).InterfaceGuid | |
| $RegPath = "HKLM:\SYSTEM\CurrentControlSet\Control\Class\{4d36e972-e325-11ce-bfc1-08002be10318}" | |
| # Find the correct subkey for this adapter | |
| $AdapterKeys = Get-ChildItem -Path $RegPath -ErrorAction SilentlyContinue | Where-Object { | |
| $_.GetValue("NetCfgInstanceId") -eq $AdapterGuid | |
| } | |
| if ($AdapterKeys) { | |
| $AdapterRegPath = $AdapterKeys[0].PSPath | |
| # Enable "Allow this device to wake the computer" | |
| Set-ItemProperty -Path $AdapterRegPath -Name "WakeOnMagicPacket" -Value "1" -Type String -ErrorAction SilentlyContinue | |
| Set-ItemProperty -Path $AdapterRegPath -Name "WakeOnPattern" -Value "1" -Type String -ErrorAction SilentlyContinue | |
| Set-ItemProperty -Path $AdapterRegPath -Name "*WakeOnMagicPacket" -Value "1" -Type String -ErrorAction SilentlyContinue | |
| Set-ItemProperty -Path $AdapterRegPath -Name "*WakeOnPattern" -Value "1" -Type String -ErrorAction SilentlyContinue | |
| # Enable PME (Power Management Event) - allows device to wake computer | |
| Set-ItemProperty -Path $AdapterRegPath -Name "PnPCapabilities" -Value 0 -Type DWord -ErrorAction SilentlyContinue | |
| Write-Host "✓ Power Management enabled via registry" -ForegroundColor Green | |
| } else { | |
| Write-Warning "Could not find adapter registry key for direct configuration" | |
| } | |
| # --- C. Configure via WMI (if available) --- | |
| try { | |
| $MagicPacketSetting = Get-WmiObject -Class MSNdis_DeviceWakeOnMagicPacketOnly -Namespace root/wmi | | |
| Where-Object { $_.InstanceName -Match [regex]::escape($PnPDeviceID) } | |
| if ($MagicPacketSetting) { | |
| if (-not $MagicPacketSetting.EnableWakeOnMagicPacketOnly) { | |
| $MagicPacketSetting.EnableWakeOnMagicPacketOnly = $true | |
| $MagicPacketSetting.psbase.Put() | |
| Write-Host "✓ WMI: Magic Packet Only enabled" -ForegroundColor Green | |
| } else { | |
| Write-Host " WMI: Magic Packet Only already enabled" -ForegroundColor Gray | |
| } | |
| } | |
| } catch { | |
| Write-Host " WMI configuration not available (using registry method instead)" -ForegroundColor Gray | |
| } | |
| # --- D. Verification --- | |
| Write-Host "" | |
| Write-Host "═══════════════════════════════════════" -ForegroundColor Cyan | |
| Write-Host "Current Configuration:" -ForegroundColor Cyan | |
| Write-Host "═══════════════════════════════════════" -ForegroundColor Cyan | |
| # Build verification object | |
| $Config = [PSCustomObject]@{ | |
| ComputerName = $env:COMPUTERNAME | |
| AdapterName = $Adapter | |
| AdapterDescription = $AdapterDescription | |
| MACAddress = (Get-NetAdapter -Name $Adapter).MacAddress | |
| } | |
| # Add common properties | |
| $WakeOnMagic = Get-NetAdapterAdvancedProperty -Name $Adapter -DisplayName "Wake on Magic Packet" -ErrorAction SilentlyContinue | |
| if ($WakeOnMagic) { | |
| $Config | Add-Member -NotePropertyName "WakeOnMagicPacket" -NotePropertyValue "$($WakeOnMagic.DisplayValue) (Reg: $($WakeOnMagic.RegistryValue))" | |
| } | |
| $WakeOnPattern = Get-NetAdapterAdvancedProperty -Name $Adapter -DisplayName "Wake on pattern match" -ErrorAction SilentlyContinue | |
| if ($WakeOnPattern) { | |
| $Config | Add-Member -NotePropertyName "WakeOnPattern" -NotePropertyValue "$($WakeOnPattern.DisplayValue) (Reg: $($WakeOnPattern.RegistryValue))" | |
| } | |
| $EEE = Get-NetAdapterAdvancedProperty -Name $Adapter -DisplayName "Energy Efficient Ethernet" -ErrorAction SilentlyContinue | |
| if ($EEE) { | |
| $Config | Add-Member -NotePropertyName "EnergyEfficientEthernet" -NotePropertyValue "$($EEE.DisplayValue) (Reg: $($EEE.RegistryValue))" | |
| } | |
| # Add Realtek-specific properties if available | |
| $ShutdownWOL = Get-NetAdapterAdvancedProperty -Name $Adapter -DisplayName "Shutdown Wake-on-LAN" -ErrorAction SilentlyContinue | |
| if ($ShutdownWOL) { | |
| $Config | Add-Member -NotePropertyName "ShutdownWakeOnLAN" -NotePropertyValue "$($ShutdownWOL.DisplayValue) (Reg: $($ShutdownWOL.RegistryValue))" | |
| } | |
| $LinkSpeed = Get-NetAdapterAdvancedProperty -Name $Adapter -DisplayName "WOL & Shutdown Link Speed" -ErrorAction SilentlyContinue | |
| if ($LinkSpeed) { | |
| $Config | Add-Member -NotePropertyName "WOLShutdownLinkSpeed" -NotePropertyValue $LinkSpeed.DisplayValue | |
| } | |
| $Config | Format-List | |
| } -ErrorAction Stop | |
| Write-Host "✓ Network adapter configuration completed." -ForegroundColor Green | |
| } | |
| catch { | |
| Write-Error "Failed to configure network adapter: $($_.Exception.Message)" | |
| exit 1 | |
| } | |
| # -------------------------------------------------------------------------------------------------- | |
| # --- Final Summary --- | |
| Write-Host "" | |
| Write-Host "╔════════════════════════════════════════════════════════════════╗" -ForegroundColor Green | |
| Write-Host "║ CONFIGURATION COMPLETE ║" -ForegroundColor Green | |
| Write-Host "╚════════════════════════════════════════════════════════════════╝" -ForegroundColor Green | |
| Write-Host "" | |
| Write-Host "⚠️ REBOOT REQUIRED" -ForegroundColor Red | |
| Write-Host "Network adapter changes require a reboot to take effect." -ForegroundColor Yellow | |
| Write-Host "" | |
| Write-Host "IMPORTANT NOTES:" -ForegroundColor Cyan | |
| Write-Host " • Modern Standby (S0) and power button settings are managed via GPO" -ForegroundColor Gray | |
| Write-Host " • Ensure GPO has been applied and machines rebooted" -ForegroundColor Gray | |
| Write-Host " • After reboot, test WOL with: shutdown /s /t 0" -ForegroundColor Gray | |
| Write-Host " • Hibernate should also support WOL (test with: shutdown /h)" -ForegroundColor Gray | |
| Write-Host "" | |
| Write-Host "Next Steps:" -ForegroundColor Yellow | |
| Write-Host " 1. Reboot the machine: Restart-Computer -ComputerName $ComputerName -Force" -ForegroundColor White | |
| Write-Host " 2. Verify GPO applied: gpresult /r" -ForegroundColor White | |
| Write-Host " 3. Check sleep states: powercfg /a" -ForegroundColor White | |
| Write-Host " 4. Test WOL from shutdown and hibernate" -ForegroundColor White | |
| Write-Host "" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <# | |
| .SYNOPSIS | |
| Comprehensive Wake-on-LAN diagnostic script for Dell machines running Windows 10/11. | |
| Gathers detailed configuration information to troubleshoot WOL issues. | |
| .PARAMETER ComputerName | |
| The target computer's hostname or IP address. | |
| .PARAMETER AdapterName | |
| Optional: Specific network adapter name to check. If not provided, discovers the primary adapter. | |
| .NOTES | |
| Requires Administrator privileges and PowerShell Remoting (WinRM). | |
| #> | |
| param( | |
| [Parameter(Mandatory=$true)] | |
| [string]$ComputerName, | |
| [string]$AdapterName | |
| ) | |
| Write-Host "=== Wake-on-LAN Diagnostic Report for $ComputerName ===" -ForegroundColor Cyan | |
| Write-Host "Generated: $(Get-Date)" -ForegroundColor Gray | |
| Write-Host "" | |
| $DiagnosticResults = Invoke-Command -ComputerName $ComputerName -ScriptBlock { | |
| param($PassedAdapterName) | |
| $Results = @{} | |
| # ============================================================================ | |
| # SECTION 1: SYSTEM INFORMATION | |
| # ============================================================================ | |
| Write-Host "[1/8] Gathering System Information..." -ForegroundColor Yellow | |
| $Results.ComputerName = $env:COMPUTERNAME | |
| $Results.OSVersion = (Get-WmiObject Win32_OperatingSystem).Caption | |
| $Results.OSBuild = (Get-WmiObject Win32_OperatingSystem).BuildNumber | |
| # Get Dell Model Info | |
| try { | |
| $Results.Manufacturer = (Get-WmiObject Win32_ComputerSystem).Manufacturer | |
| $Results.Model = (Get-WmiObject Win32_ComputerSystem).Model | |
| $Results.BIOSVersion = (Get-WmiObject Win32_BIOS).SMBIOSBIOSVersion | |
| } catch { | |
| $Results.Manufacturer = "Unknown" | |
| $Results.Model = "Unknown" | |
| } | |
| # ============================================================================ | |
| # SECTION 2: NETWORK ADAPTER DISCOVERY & SELECTION | |
| # ============================================================================ | |
| Write-Host "[2/8] Discovering Network Adapters..." -ForegroundColor Yellow | |
| $AllAdapters = Get-NetAdapter -Physical | Where-Object { $_.Status -ne "Disabled" } | Select-Object Name, Status, MediaType, MacAddress, InterfaceDescription | |
| $Results.AllAdapters = $AllAdapters | Format-Table | Out-String | |
| # Determine which adapter to analyze | |
| if ($PassedAdapterName -and (Get-NetAdapter -Name $PassedAdapterName -ErrorAction SilentlyContinue)) { | |
| $TargetAdapter = Get-NetAdapter -Name $PassedAdapterName | |
| } else { | |
| $TargetAdapter = Get-NetAdapter -Physical | Where-Object { | |
| ($_.MediaType -eq "802.3") -and ($_.Status -ne "Disabled") | |
| } | Select-Object -First 1 | |
| } | |
| if (-not $TargetAdapter) { | |
| throw "No suitable network adapter found!" | |
| } | |
| $Results.TargetAdapterName = $TargetAdapter.Name | |
| $Results.TargetAdapterMAC = $TargetAdapter.MacAddress | |
| $Results.TargetAdapterStatus = $TargetAdapter.Status | |
| $Results.TargetAdapterDescription = $TargetAdapter.InterfaceDescription | |
| $PnPDeviceID = $TargetAdapter.PnPDeviceID | |
| # ============================================================================ | |
| # SECTION 3: BIOS/UEFI WOL SETTINGS (Dell) | |
| # ============================================================================ | |
| Write-Host "[3/8] Checking BIOS/UEFI WOL Settings..." -ForegroundColor Yellow | |
| try { | |
| Import-Module DellBIOSProvider -ErrorAction Stop | |
| $Results.DellBIOSProvider = "Installed" | |
| # Wake on LAN setting | |
| $WOLSetting = Get-Item -Path DellSmbios:\PowerManagement\WakeOnLan -ErrorAction SilentlyContinue | |
| $Results.BIOS_WakeOnLAN = if ($WOLSetting) { $WOLSetting.CurrentValue } else { "Not Available" } | |
| # Deep Sleep Control | |
| $DeepSleep = Get-Item -Path DellSmbios:\PowerManagement\DeepSleepCtrl -ErrorAction SilentlyContinue | |
| $Results.BIOS_DeepSleepCtrl = if ($DeepSleep) { $DeepSleep.CurrentValue } else { "Not Available" } | |
| # Block Sleep (S3 State) | |
| $BlockSleep = Get-Item -Path DellSmbios:\PowerManagement\BlockSleep -ErrorAction SilentlyContinue | |
| $Results.BIOS_BlockSleep = if ($BlockSleep) { $BlockSleep.CurrentValue } else { "Not Available" } | |
| # AC Power Recovery | |
| $ACRecovery = Get-Item -Path DellSmbios:\PowerManagement\AcPwrRcvry -ErrorAction SilentlyContinue | |
| $Results.BIOS_ACPowerRecovery = if ($ACRecovery) { $ACRecovery.CurrentValue } else { "Not Available" } | |
| # Wake on AC | |
| $WakeOnAC = Get-Item -Path DellSmbios:\PowerManagement\WakeOnAc -ErrorAction SilentlyContinue | |
| $Results.BIOS_WakeOnAC = if ($WakeOnAC) { $WakeOnAC.CurrentValue } else { "Not Available" } | |
| } catch { | |
| $Results.DellBIOSProvider = "Not Installed or Error: $($_.Exception.Message)" | |
| $Results.BIOS_WakeOnLAN = "Unable to check" | |
| } | |
| # ============================================================================ | |
| # SECTION 4: NETWORK ADAPTER ADVANCED PROPERTIES | |
| # ============================================================================ | |
| Write-Host "[4/8] Checking Network Adapter Advanced Properties..." -ForegroundColor Yellow | |
| $AdvancedProps = Get-NetAdapterAdvancedProperty -Name $TargetAdapter.Name | |
| $Results.AllAdvancedProperties = $AdvancedProps | Select-Object DisplayName, DisplayValue, RegistryValue | Format-Table | Out-String | |
| # Key WOL properties | |
| $KeyProperties = @( | |
| "Wake on Magic Packet", | |
| "Wake on pattern match", | |
| "Shutdown Wake-on-LAN", | |
| "WOL & Shutdown Link Speed", | |
| "Energy Efficient Ethernet", | |
| "Advanced EEE", | |
| "Green Ethernet", | |
| "Power Saving Mode", | |
| "Ultra Low Power Mode" | |
| ) | |
| foreach ($PropName in $KeyProperties) { | |
| $Prop = $AdvancedProps | Where-Object { $_.DisplayName -eq $PropName } | |
| if ($Prop) { | |
| $Results."Adv_$($PropName -replace ' ','')" = "$($Prop.DisplayValue) (Registry: $($Prop.RegistryValue))" | |
| } else { | |
| $Results."Adv_$($PropName -replace ' ','')" = "Not Available" | |
| } | |
| } | |
| # ============================================================================ | |
| # SECTION 5: POWER MANAGEMENT SETTINGS (WMI) | |
| # ============================================================================ | |
| Write-Host "[5/8] Checking Power Management Settings..." -ForegroundColor Yellow | |
| # Magic Packet Only setting | |
| $MagicPacketOnly = Get-WmiObject -Class MSNdis_DeviceWakeOnMagicPacketOnly -Namespace root/wmi | | |
| Where-Object { $_.InstanceName -Match [regex]::escape($PnPDeviceID) } | |
| $Results.PowerMgmt_MagicPacketOnly = if ($MagicPacketOnly) { $MagicPacketOnly.EnableWakeOnMagicPacketOnly } else { "Not Available" } | |
| # Wake on Pattern Match | |
| $PatternMatch = Get-WmiObject -Class MSPower_DeviceWakeEnable -Namespace root/wmi | | |
| Where-Object { $_.InstanceName -Match [regex]::escape($PnPDeviceID) } | |
| $Results.PowerMgmt_DeviceWakeEnable = if ($PatternMatch) { $PatternMatch.Enable } else { "Not Available" } | |
| # Allow device to wake computer (from Device Manager) | |
| $AllowWake = Get-WmiObject -Class MSPower_DeviceEnable -Namespace root/wmi | | |
| Where-Object { $_.InstanceName -Match [regex]::escape($PnPDeviceID) } | |
| $Results.PowerMgmt_AllowDeviceToWake = if ($AllowWake) { $AllowWake.Enable } else { "Not Available" } | |
| # ============================================================================ | |
| # SECTION 6: WINDOWS POWER SETTINGS | |
| # ============================================================================ | |
| Write-Host "[6/8] Checking Windows Power Settings..." -ForegroundColor Yellow | |
| # Fast Startup Status (THIS IS CRITICAL!) | |
| $FastStartup = Get-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Power" -Name HiberbootEnabled -ErrorAction SilentlyContinue | |
| $Results.FastStartup = if ($FastStartup) { | |
| if ($FastStartup.HiberbootEnabled -eq 1) { "ENABLED (BAD for S5 WOL!)" } else { "Disabled (Good)" } | |
| } else { "Unknown" } | |
| # Hibernate Enabled | |
| $HibernateEnabled = (powercfg /a | Select-String "Hibernate").Count -gt 0 | |
| $Results.HibernateAvailable = $HibernateEnabled | |
| # Current Power Plan | |
| $ActivePlan = powercfg /getactivescheme | |
| $Results.ActivePowerPlan = ($ActivePlan -split '\s+')[3] | |
| # Network adapter power settings for active plan | |
| $PlanGuid = ($ActivePlan -split '\s+')[3] | |
| # Allow computer to turn off this device to save power | |
| $AllowPowerOff = powercfg /q $PlanGuid SUB_NONE | Select-String -Pattern "Allow the computer to turn off this device" -Context 0,10 | |
| $Results.PowerPlan_AllowPowerOff = if ($AllowPowerOff) { "Check output below" } else { "Not found in active plan" } | |
| # ============================================================================ | |
| # SECTION 7: SLEEP STATES & CAPABILITIES | |
| # ============================================================================ | |
| Write-Host "[7/8] Checking Sleep State Capabilities..." -ForegroundColor Yellow | |
| $PowerCfgA = powercfg /a | Out-String | |
| $Results.AvailableSleepStates = $PowerCfgA | |
| # Check what happens on power button press | |
| $PowerButtonAction = powercfg /q $PlanGuid SUB_BUTTONS PBUTTONACTION | Out-String | |
| $Results.PowerButtonAction = $PowerButtonAction | |
| # Check what happens on sleep button press | |
| $SleepButtonAction = powercfg /q $PlanGuid SUB_BUTTONS SBUTTONACTION | Out-String | |
| $Results.SleepButtonAction = $SleepButtonAction | |
| # Lid close action (for laptops) | |
| $LidCloseAction = powercfg /q $PlanGuid SUB_BUTTONS LIDACTION | Out-String | |
| $Results.LidCloseAction = $LidCloseAction | |
| # ============================================================================ | |
| # SECTION 8: RECENT POWER EVENTS | |
| # ============================================================================ | |
| Write-Host "[8/8] Checking Recent Power/Sleep Events..." -ForegroundColor Yellow | |
| # Get recent sleep/wake events from Event Log | |
| $PowerEvents = Get-WinEvent -FilterHashtable @{ | |
| LogName = 'System' | |
| ProviderName = 'Microsoft-Windows-Power-Troubleshooter', 'Microsoft-Windows-Kernel-Power' | |
| StartTime = (Get-Date).AddDays(-7) | |
| } -MaxEvents 50 -ErrorAction SilentlyContinue | | |
| Select-Object TimeCreated, Id, Message | | |
| Format-Table -AutoSize | Out-String | |
| $Results.RecentPowerEvents = if ($PowerEvents) { $PowerEvents } else { "No recent power events found" } | |
| # Check for Modern Standby (S0ix) vs Traditional Sleep (S3) | |
| $StandbyType = Get-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Power" -Name PlatformAoAcOverride -ErrorAction SilentlyContinue | |
| $Results.ModernStandby = if ($StandbyType) { | |
| # PlatformAoAcOverride exists | |
| if ($StandbyType.PlatformAoAcOverride -eq 0) { | |
| "Modern Standby DISABLED (Good)" | |
| } elseif ($StandbyType.PlatformAoAcOverride -eq 1) { | |
| "Modern Standby ENFORCED (Bad)" | |
| } else { | |
| "Unknown override value: $($StandbyType.PlatformAoAcOverride)" | |
| } | |
| } else { | |
| # PlatformAoAcOverride doesn't exist - check powercfg /a to determine actual state | |
| if ($PowerCfgA -match "Standby \(S0 Low Power Idle\)") { | |
| "Modern Standby (S0) ENABLED by default - WOL may not work from sleep!" | |
| } elseif ($PowerCfgA -match "Standby \(S3\)") { | |
| "Traditional S3 Sleep available - (Good)" | |
| } else { | |
| "No sleep states available (only shutdown/hibernate) - Check powercfg /a" | |
| } | |
| } | |
| return $Results | |
| } -ArgumentList $AdapterName | |
| # ============================================================================ | |
| # OUTPUT RESULTS IN ORGANIZED FORMAT | |
| # ============================================================================ | |
| Write-Host "" | |
| Write-Host "╔════════════════════════════════════════════════════════════════╗" -ForegroundColor Cyan | |
| Write-Host "║ SYSTEM INFORMATION ║" -ForegroundColor Cyan | |
| Write-Host "╚════════════════════════════════════════════════════════════════╝" -ForegroundColor Cyan | |
| Write-Host "Computer Name: $($DiagnosticResults.ComputerName)" | |
| Write-Host "Manufacturer: $($DiagnosticResults.Manufacturer)" | |
| Write-Host "Model: $($DiagnosticResults.Model)" | |
| Write-Host "BIOS Version: $($DiagnosticResults.BIOSVersion)" | |
| Write-Host "OS Version: $($DiagnosticResults.OSVersion)" | |
| Write-Host "OS Build: $($DiagnosticResults.OSBuild)" | |
| Write-Host "" | |
| Write-Host "╔════════════════════════════════════════════════════════════════╗" -ForegroundColor Cyan | |
| Write-Host "║ TARGET NETWORK ADAPTER ║" -ForegroundColor Cyan | |
| Write-Host "╚════════════════════════════════════════════════════════════════╝" -ForegroundColor Cyan | |
| Write-Host "Adapter Name: $($DiagnosticResults.TargetAdapterName)" | |
| Write-Host "MAC Address: $($DiagnosticResults.TargetAdapterMAC)" | |
| Write-Host "Status: $($DiagnosticResults.TargetAdapterStatus)" | |
| Write-Host "Description: $($DiagnosticResults.TargetAdapterDescription)" | |
| Write-Host "" | |
| Write-Host "╔════════════════════════════════════════════════════════════════╗" -ForegroundColor Cyan | |
| Write-Host "║ BIOS/UEFI WOL SETTINGS ║" -ForegroundColor Cyan | |
| Write-Host "╚════════════════════════════════════════════════════════════════╝" -ForegroundColor Cyan | |
| Write-Host "DellBIOSProvider: $($DiagnosticResults.DellBIOSProvider)" | |
| Write-Host "Wake on LAN: $($DiagnosticResults.BIOS_WakeOnLAN)" -ForegroundColor $(if ($DiagnosticResults.BIOS_WakeOnLAN -like "*LanOnly*" -or $DiagnosticResults.BIOS_WakeOnLAN -like "*Enabled*") { "Green" } else { "Red" }) | |
| Write-Host "Deep Sleep Ctrl: $($DiagnosticResults.BIOS_DeepSleepCtrl)" -ForegroundColor $(if ($DiagnosticResults.BIOS_DeepSleepCtrl -like "*Disabled*") { "Green" } else { "Yellow" }) | |
| Write-Host "Block Sleep: $($DiagnosticResults.BIOS_BlockSleep)" | |
| Write-Host "AC Power Recovery: $($DiagnosticResults.BIOS_ACPowerRecovery)" | |
| Write-Host "Wake on AC: $($DiagnosticResults.BIOS_WakeOnAC)" | |
| Write-Host "" | |
| Write-Host "╔════════════════════════════════════════════════════════════════╗" -ForegroundColor Cyan | |
| Write-Host "║ ADAPTER ADVANCED PROPERTIES ║" -ForegroundColor Cyan | |
| Write-Host "╚════════════════════════════════════════════════════════════════╝" -ForegroundColor Cyan | |
| Write-Host "Wake on Magic Packet: $($DiagnosticResults.Adv_WakeonMagicPacket)" -ForegroundColor $(if ($DiagnosticResults.Adv_WakeonMagicPacket -like "*Enabled*" -or $DiagnosticResults.Adv_WakeonMagicPacket -like "*(Registry: 1)*") { "Green" } else { "Red" }) | |
| Write-Host "Wake on Pattern Match: $($DiagnosticResults.Adv_Wakeonpatternmatch)" -ForegroundColor $(if ($DiagnosticResults.Adv_Wakeonpatternmatch -like "*Enabled*" -or $DiagnosticResults.Adv_Wakeonpatternmatch -like "*(Registry: 1)*") { "Green" } else { "Yellow" }) | |
| Write-Host "Shutdown Wake-on-LAN: $($DiagnosticResults.'Adv_ShutdownWake-on-LAN')" -ForegroundColor $(if ($DiagnosticResults.'Adv_ShutdownWake-on-LAN' -like "*Enabled*" -or $DiagnosticResults.'Adv_ShutdownWake-on-LAN' -like "*(Registry: 1)*") { "Green" } else { "Red" }) | |
| Write-Host "WOL & Shutdown Link Speed: $($DiagnosticResults.'Adv_WOL&ShutdownLinkSpeed')" | |
| Write-Host "Energy Efficient Ethernet: $($DiagnosticResults.Adv_EnergyEfficientEthernet)" -ForegroundColor $(if ($DiagnosticResults.Adv_EnergyEfficientEthernet -like "*Disabled*" -or $DiagnosticResults.Adv_EnergyEfficientEthernet -like "*(Registry: 0)*") { "Green" } else { "Yellow" }) | |
| Write-Host "Advanced EEE: $($DiagnosticResults.Adv_AdvancedEEE)" | |
| Write-Host "Green Ethernet: $($DiagnosticResults.Adv_GreenEthernet)" | |
| Write-Host "Power Saving Mode: $($DiagnosticResults.Adv_PowerSavingMode)" | |
| Write-Host "" | |
| Write-Host "╔════════════════════════════════════════════════════════════════╗" -ForegroundColor Cyan | |
| Write-Host "║ POWER MANAGEMENT (WMI) ║" -ForegroundColor Cyan | |
| Write-Host "╚════════════════════════════════════════════════════════════════╝" -ForegroundColor Cyan | |
| Write-Host "Magic Packet Only: $($DiagnosticResults.PowerMgmt_MagicPacketOnly)" -ForegroundColor $(if ($DiagnosticResults.PowerMgmt_MagicPacketOnly -eq $true) { "Green" } else { "Yellow" }) | |
| Write-Host "Device Wake Enable: $($DiagnosticResults.PowerMgmt_DeviceWakeEnable)" -ForegroundColor $(if ($DiagnosticResults.PowerMgmt_DeviceWakeEnable -eq $true) { "Green" } else { "Red" }) | |
| Write-Host "Allow Device to Wake: $($DiagnosticResults.PowerMgmt_AllowDeviceToWake)" -ForegroundColor $(if ($DiagnosticResults.PowerMgmt_AllowDeviceToWake -eq $true) { "Green" } else { "Red" }) | |
| Write-Host "" | |
| Write-Host "╔════════════════════════════════════════════════════════════════╗" -ForegroundColor Red | |
| Write-Host "║ ⚠️ CRITICAL WINDOWS POWER SETTINGS ⚠️ ║" -ForegroundColor Red | |
| Write-Host "╚════════════════════════════════════════════════════════════════╝" -ForegroundColor Red | |
| Write-Host "Fast Startup: $($DiagnosticResults.FastStartup)" -ForegroundColor $(if ($DiagnosticResults.FastStartup -like "*Disabled*") { "Green" } else { "Red" }) | |
| Write-Host "Hibernate Available: $($DiagnosticResults.HibernateAvailable)" | |
| Write-Host "Active Power Plan: $($DiagnosticResults.ActivePowerPlan)" | |
| Write-Host "Modern Standby Status: $($DiagnosticResults.ModernStandby)" -ForegroundColor $(if ($DiagnosticResults.ModernStandby -like "*Good*") { "Green" } else { "Red" }) | |
| Write-Host "" | |
| Write-Host "╔════════════════════════════════════════════════════════════════╗" -ForegroundColor Cyan | |
| Write-Host "║ SLEEP STATE CAPABILITIES ║" -ForegroundColor Cyan | |
| Write-Host "╚════════════════════════════════════════════════════════════════╝" -ForegroundColor Cyan | |
| Write-Host $DiagnosticResults.AvailableSleepStates | |
| Write-Host "" | |
| Write-Host "╔════════════════════════════════════════════════════════════════╗" -ForegroundColor Cyan | |
| Write-Host "║ POWER/SLEEP BUTTON ACTIONS ║" -ForegroundColor Cyan | |
| Write-Host "╚════════════════════════════════════════════════════════════════╝" -ForegroundColor Cyan | |
| Write-Host "--- Power Button Action ---" | |
| Write-Host $DiagnosticResults.PowerButtonAction | |
| Write-Host "" | |
| Write-Host "--- Sleep Button Action ---" | |
| Write-Host $DiagnosticResults.SleepButtonAction | |
| Write-Host "" | |
| Write-Host "--- Lid Close Action (Laptops) ---" | |
| Write-Host $DiagnosticResults.LidCloseAction | |
| Write-Host "" | |
| Write-Host "╔════════════════════════════════════════════════════════════════╗" -ForegroundColor Yellow | |
| Write-Host "║ TROUBLESHOOTING SUMMARY ║" -ForegroundColor Yellow | |
| Write-Host "╚════════════════════════════════════════════════════════════════╝" -ForegroundColor Yellow | |
| Write-Host "" | |
| # Analyze and provide recommendations | |
| $Issues = @() | |
| $Warnings = @() | |
| if ($DiagnosticResults.FastStartup -like "*ENABLED*") { | |
| $Issues += "❌ CRITICAL: Fast Startup is ENABLED. This prevents WOL from S5 (full shutdown)." | |
| } | |
| if ($DiagnosticResults.ModernStandby -notlike "*Good*") { | |
| $Issues += "❌ CRITICAL: Modern Standby (S0) detected. WOL typically doesn't work from Modern Standby sleep states." | |
| } | |
| if ($DiagnosticResults.PowerMgmt_AllowDeviceToWake -ne $true) { | |
| $Issues += "❌ 'Allow this device to wake the computer' is NOT enabled in Power Management." | |
| } | |
| if ($DiagnosticResults.'Adv_ShutdownWake-on-LAN' -notlike "*Enabled*" -and $DiagnosticResults.'Adv_ShutdownWake-on-LAN' -notlike "*(Registry: 1)*") { | |
| $Issues += "❌ 'Shutdown Wake-on-LAN' advanced property is NOT enabled." | |
| } | |
| if ($DiagnosticResults.BIOS_DeepSleepCtrl -notlike "*Disabled*" -and $DiagnosticResults.BIOS_DeepSleepCtrl -ne "Not Available") { | |
| $Warnings += "⚠️ Deep Sleep Control is not disabled in BIOS. This may interfere with WOL." | |
| } | |
| if ($DiagnosticResults.Adv_EnergyEfficientEthernet -notlike "*Disabled*" -and $DiagnosticResults.Adv_EnergyEfficientEthernet -notlike "*(Registry: 0)*" -and $DiagnosticResults.Adv_EnergyEfficientEthernet -ne "Not Available") { | |
| $Warnings += "⚠️ Energy Efficient Ethernet is not disabled. This can interfere with WOL." | |
| } | |
| # Check if power button causes sleep or shutdown | |
| if ($DiagnosticResults.PowerButtonAction -like "*0x00000001*") { | |
| $Warnings += "⚠️ Power button is set to SLEEP. If Modern Standby is enabled, WOL won't work." | |
| } elseif ($DiagnosticResults.PowerButtonAction -like "*0x00000002*") { | |
| $Issues += "❌ Power button is set to HIBERNATE. WOL may not work from hibernate." | |
| } | |
| if ($Issues.Count -eq 0 -and $Warnings.Count -eq 0) { | |
| Write-Host "✅ No critical issues detected! Configuration looks good." -ForegroundColor Green | |
| } else { | |
| if ($Issues.Count -gt 0) { | |
| Write-Host "CRITICAL ISSUES FOUND:" -ForegroundColor Red | |
| $Issues | ForEach-Object { Write-Host $_ -ForegroundColor Red } | |
| Write-Host "" | |
| } | |
| if ($Warnings.Count -gt 0) { | |
| Write-Host "WARNINGS:" -ForegroundColor Yellow | |
| $Warnings | ForEach-Object { Write-Host $_ -ForegroundColor Yellow } | |
| Write-Host "" | |
| } | |
| } | |
| Write-Host "" | |
| Write-Host "╔════════════════════════════════════════════════════════════════╗" -ForegroundColor Green | |
| Write-Host "║ RECOMMENDED ACTIONS ║" -ForegroundColor Green | |
| Write-Host "╚════════════════════════════════════════════════════════════════╝" -ForegroundColor Green | |
| Write-Host "" | |
| Write-Host "1. Disable Fast Startup (if enabled)" -ForegroundColor Cyan | |
| Write-Host " Control Panel → Power Options → Choose what power buttons do → Change settings currently unavailable → Uncheck 'Turn on fast startup'" | |
| Write-Host "" | |
| Write-Host "2. If Modern Standby is detected:" -ForegroundColor Cyan | |
| Write-Host " Consider using Hibernate or full shutdown instead of Sleep for reliable WOL." | |
| Write-Host " Or: Disable Modern Standby via registry (requires reboot):" | |
| Write-Host " reg add HKLM\System\CurrentControlSet\Control\Power /v PlatformAoAcOverride /t REG_DWORD /d 0 /f" | |
| Write-Host "" | |
| Write-Host "3. Ensure 'Allow this device to wake the computer' is checked in Device Manager" -ForegroundColor Cyan | |
| Write-Host " Device Manager → Network Adapters → [Your Adapter] → Properties → Power Management" | |
| Write-Host "" | |
| Write-Host "4. Test WOL from different power states:" -ForegroundColor Cyan | |
| Write-Host " - Full shutdown: shutdown /s /t 0" -ForegroundColor Gray | |
| Write-Host " - Hybrid shutdown (Fast Startup): shutdown /s /hybrid /t 0" -ForegroundColor Gray | |
| Write-Host " - Sleep (S3): rundll32.exe powrprof.dll,SetSuspendState Sleep" -ForegroundColor Gray | |
| Write-Host " - Hibernate: shutdown /h" -ForegroundColor Gray | |
| Write-Host "" | |
| Write-Host "=== Diagnostic Report Complete ===" -ForegroundColor Cyan | |
| Write-Host "" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Hive HKEY_LOCAL_MACHINE | |
| Key path SYSTEM\CurrentControlSet\Control\Session Manager\Power | |
| Value name HiberbootEnabled | |
| Value type REG_DWORD | |
| Value data 0x0 (0) | |
| Hive HKEY_LOCAL_MACHINE | |
| Key path SYSTEM\CurrentControlSet\Control\Power | |
| Value name PlatformAoAcOverride | |
| Value type REG_DWORD | |
| Value data 0x0 (0) | |
| Hive HKEY_LOCAL_MACHINE | |
| Key path SYSTEM\CurrentControlSet\Control\Power | |
| Value name CsEnabled | |
| Value type REG_DWORD | |
| Value data 0x0 (0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment