We have created a Enable-WOL script to enable Wake on Lan in the BIOS for Dell, HP en Lenovo devices.
But unfortunately this script doesn’t work.
We have created this script:
Note This script has not been tested rigorously - 2021-03-11 - Merge Requests accepted!
$Manufacturer = Get-WmiObject Win32_Computersystem -Property Manufacturer | select -ExpandProperty manufacturer
if($Manufacturer -like “Dell*”)
{
if((Get-Module -ListAvailable -Name DellBiosProvider) -eq $null)
{
Install-Module DellBiosProvider -Confirm:$false -Force
}
Import-Module DellBiosProvider
$WakeOnLanDisabled = (Get-Item “DellSmbios:\PowerManagement\WakeOnlan” | select -ExpandProperty CurrentValue) -like “Disabled”
if($WakeOnLanDisabled)
{
“WakeOnLan is Disabled…Enabling”
Set-Item “DellSmbios:\PowerManagement\WakeOnlan” -Value LanWlan
}
else
{
“WakeOnLan already enabled”
}
}
elseif($Manufacturer -like “hp”)
{
$WMI = Get-WmiObject -Namespace “root\hp\instrumentedBIOS” -Class hp_biosSetting -ErrorAction Stop | where { ![string]::IsNullOrWhiteSpace($.Name) -and $.Name -like “S5 Wake on LAN”} | select Name,Value,IsReadOnly | Sort-Object name
$WakeOnLanDisabled = ($WMI | select -ExpandProperty Value) -match “*Disable”
if($WakeOnLanDisabled)
{
“WakeOnLan is Disabled…Enabling”
$setBiosSetting = Get-WmiObject -Namespace “root\hp\instrumentedbios” -Class HP_BiosSettingInterface
$setBiosSetting.SetBIOSSetting(“S5 Wake on LAN”,“Enable”)
}
else
{
“WakeOnLan already enabled”
}
}
elseif($manufacturer -like “lenovo”)
{
$WMI = Get-WmiObject -class Lenovo_BiosSetting -namespace “root\wmi”
$BIOSsettings = New-Object PSObject
$BIOSsettings | Add-Member -MemberType NoteProperty -Name ‘ComputerName’ -Value $WMI[0].__Server
$WMI | ?{![string]::IsNullOrWhiteSpace($.CurrentSetting)}| %{
$Setting = $.CurrentSetting -split ‘,’;
$BIOSsettings | Add-Member -MemberType NoteProperty -Name $Setting[0] -Value $Setting[1] -Force;
}
$WakeOnLanDisabled = ($BIOSSettings | select -ExpandProperty wakeonlan) -like “Disable”
if($WakeOnLanDisabled)
{
“WakeOnLan is Disabled…Enabling”
(gwmi -class Lenovo_SetBiosSetting –namespace root\wmi).SetBiosSetting(“WakeOnLAN,ACOnly”)
(gwmi -class Lenovo_SaveBiosSettings -namespace root\wmi).SaveBiosSettings()
}
else
{
“WakeOnLan already enabled”
}
}
Could you provide us with a script that enables Wake on Lan in the bios?