Skip to content

Instantly share code, notes, and snippets.

@kamronbatman
Created November 12, 2025 02:19
Show Gist options
  • Select an option

  • Save kamronbatman/5885af2d0212c33c27d6b62b42e96f57 to your computer and use it in GitHub Desktop.

Select an option

Save kamronbatman/5885af2d0212c33c27d6b62b42e96f57 to your computer and use it in GitHub Desktop.
Configures Dell & Windows Wake-on-LAN Remotely using Powershell
<#
.SYNOPSIS
Remotely enables Wake-on-LAN (WOL) in both BIOS and Windows Network Adapter settings on a Dell machine,
following Dell's best practices.
.PARAMETER ComputerName
The target Dell computer's hostname or IP address.
.PARAMETER AdapterName
The name of the network adapter to configure (e.g., "Ethernet", "Ethernet 2").
Defaults to the first active ethernet.
.NOTES
Requires Administrator privileges on the machine running the script (your server)
and on the target client machine via PowerShell Remoting (WinRM).
REMINDER: Windows Fast Startup MUST be DISABLED on the client for S5/shutdown WOL to work.
#>
param(
[Parameter(Mandatory=$true)]
[string]$ComputerName,
[string]$AdapterName = "Ethernet"
)
$BIOSSetting = "LanOnly"
Write-Host "--- Starting FULL WOL Configuration on $($ComputerName) ---" -ForegroundColor Cyan
# --- 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
}
Write-Host "PowerShellGet updated successfully." -ForegroundColor Green
}
catch {
Write-Error "Failed to update PowerShellGet on $($ComputerName). Error: $($_.Exception.Message)"
exit 1
}
# --------------------------------------------------------------------------------------------------
# --- Step 2: Configure WOL in BIOS ---
try {
Write-Host "2/3: Installing DellBIOSProvider and setting BIOS WOL to $($BIOSSetting)..." -ForegroundColor Yellow
Invoke-Command -ComputerName $ComputerName -ScriptBlock {
param([string]$SettingValue)
Install-Module -Name DellBIOSProvider -Force -Scope AllUsers
Import-Module DellBIOSProvider
# Apply the WOL setting
Set-Item -Path DellSmbios:\PowerManagement\WakeOnLan $SettingValue
# Apply the DeepSleepCtrl setting (Recommended to be Disabled)
# Note: If this option doesn't exist on the model, this command will error out.
Write-Host "Disabling Deep Sleep Control..."
Set-Item -Path DellSmbios:\PowerManagement\DeepSleepCtrl Disabled
# Validation
$CurrentSetting = (Get-Item -Path DellSmbios:\PowerManagement\WakeOnLan).CurrentValue
$DeepSleepStatus = (Get-Item -Path DellSmbios:\PowerManagement\DeepSleepCtrl).CurrentValue -replace ' '
Write-Host "Verification (BIOS): WOL set to $($CurrentSetting)"
Write-Host "Verification (BIOS): Deep Sleep Control set to $($DeepSleepStatus)"
} -ArgumentList $BIOSSetting
Write-Host "WOL BIOS setting staged successfully." -ForegroundColor Green
}
catch {
Write-Error "Failed to set BIOS configuration on $($ComputerName). Error: $($_.Exception.Message)"
exit 1
}
# --------------------------------------------------------------------------------------------------
# --- Step 3: Configure Network Adapter WOL Settings in Windows ---
try {
Write-Host "3/3: Configuring Windows Network Adapter settings for WOL..." -ForegroundColor Yellow
Invoke-Command -ComputerName $ComputerName -ScriptBlock {
param($AdapterName) # Receive the name passed by user, if any
# 1. Dynamic Adapter Discovery (prioritizes wired connections)
$TargetAdapter = Get-NetAdapter -Physical | Where-Object {
($_.MediaType -eq "802.3") -and ($_.Status -ne "Disabled")
} | Select-Object -First 1
# If user passed a specific name AND it exists, use it. Otherwise, use the discovered adapter.
if ($AdapterName -and (Get-NetAdapter -Name $AdapterName -ErrorAction SilentlyContinue)) {
$Adapter = $AdapterName
} elseif ($TargetAdapter) {
$Adapter = $TargetAdapter.Name
} else {
throw "Failed to find a suitable physical wired network adapter on the machine."
}
Write-Host "Targeting adapter: '$Adapter'"
# Get PnP ID for WMI access
$PnPDeviceID = (Get-NetAdapter -Name $Adapter).PnPDeviceID
# --- A. Configure Advanced Properties (Dell Best Practices) ---
$AdvancedSettings = @{
"Shutdown Wake-on-LAN" = 1; # 1 = Enabled
"Wake on Magic Packet" = 1; # 1 = Enabled
"Wake on pattern match" = 1; # 1 = Enabled
"WOL & Shutdown Link Speed" = "10 Mbps First"; # Use the display string
"Energy Efficient Ethernet" = 0; # 0 = Disabled
}
foreach ($Key in $AdvancedSettings.Keys) {
Write-Host "Setting Advanced Property '$Key'..."
try {
Set-NetAdapterAdvancedProperty -Name $Adapter -DisplayName $Key -RegistryValue $AdvancedSettings[$Key] -ErrorAction Stop
}
catch {
Write-Warning "Could not set Advanced Property '$Key'. This property may not exist on this NIC model."
}
}
# --- B. Configure Power Management Checkboxes (Magic Packet Only) ---
$MagicPacketSetting = Get-WmiObject -Class MSNdis_DeviceWakeOnMagicPacketOnly -Namespace root/wmi | Where-Object { $_.InstanceName -Match [regex]::escape($PnPDeviceID) }
if ($MagicPacketSetting -and -not $MagicPacketSetting.EnableWakeOnMagicPacketOnly) {
Write-Host "Setting 'Only allow a magic packet' to True..."
$MagicPacketSetting.EnableWakeOnMagicPacketOnly = $true
$MagicPacketSetting.psbase.Put()
}
# --- C. Final Verification (Includes EEE) ---
$FinalMagic = (Get-WmiObject -Class MSNdis_DeviceWakeOnMagicPacketOnly -Namespace root/wmi | Where-Object { $_.InstanceName -Match [regex]::escape($PnPDeviceID) }).EnableWakeOnMagicPacketOnly
[PSCustomObject]@{
ComputerName = $using:ComputerName
AdapterName = $Adapter
PowerMgmt_MagicOnly = $FinalMagic
Adv_ShutdownWOL = (Get-NetAdapterAdvancedProperty -Name $Adapter -DisplayName "Shutdown Wake-on-LAN" -ErrorAction SilentlyContinue).RegistryValue
Adv_WOLMagicPacket = (Get-NetAdapterAdvancedProperty -Name $Adapter -DisplayName "Wake on Magic Packet" -ErrorAction SilentlyContinue).RegistryValue
Adv_WOLPatternMatch = (Get-NetAdapterAdvancedProperty -Name $Adapter -DisplayName "Wake on pattern match" -ErrorAction SilentlyContinue).RegistryValue
Adv_EnergyEfficientEth = (Get-NetAdapterAdvancedProperty -Name $Adapter -DisplayName "Energy Efficient Ethernet" -ErrorAction SilentlyContinue).RegistryValue
} | Format-List
} -ArgumentList $AdapterName
Write-Host "Network adapter settings successfully configured." -ForegroundColor Green
}
catch {
Write-Error "Failed to configure Network Adapter settings on $($ComputerName). Error: $($_.Exception.Message)"
exit 1
}
Write-Host ""
Write-Host "--- Script Execution Complete ---" -ForegroundColor Cyan
Write-Host "ACTION REQUIRED: Please ensure **Windows Fast Startup** is DISABLED and **RESTART** $($ComputerName) for all changes to take effect." -ForegroundColor Red
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment