Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## Related post http://www.systanddeploy.com/2019/03/list-and-change-bios-settings-with.html
- Function Get_HP_BIOS_Settings
- {
- $Script:Get_BIOS_Settings = Get-WmiObject -Namespace root/hp/instrumentedBIOS -Class hp_biosEnumeration -ErrorAction SilentlyContinue | % { New-Object psobject -Property @{
- Setting = $_."Name"
- Value = $_."currentvalue"
- Available_Values = $_."PossibleValues"
- }} | select-object Setting, Value, Available_Values
- $Get_BIOS_Settings
- }
- $Z = Get_HP_BIOS_Settings
- $z | ? {$_.Setting -in ("Remote Wakeup Boot Source","S5 Maximum Power Savings")}
- ## Is password set
- $IsPasswordSet = Get-WmiObject -Namespace root/hp/instrumentedBIOS -Class HP_BIOSSettingInterface
- If($IsPasswordSet -eq 1){write-host "Password is configured"}Else{write-host "No BIOS password"}
- ## Enabled WOL no BIOS password
- $bios = Get-WmiObject -Namespace root/hp/instrumentedBIOS -Class HP_BIOSSettingInterface
- $bios.setbiossetting("Remote Wakeup Boot Source", "Remote Server","") | out-null
- $bios.setbiossetting("S5 Maximum Power Savings", "Disable","") | out-null
- ## Enable with BIOS password
- $MyPassword = "password123456"
- $Password_To_Use = "<utf-16></utf>"+$MyPassword
- $bios = Get-WmiObject -Namespace root/hp/instrumentedBIOS -Class HP_BIOSSettingInterface
- $bios.setbiossetting("$MySetting", "$NewValue",$Password_To_Use) | out-null
- $bios.setbiossetting("Remote Wakeup Boot Source", "Remote Server", $Password_To_Use) | out-null
- $bios.setbiossetting("S5 Maximum Power Savings", "Disable", $Password_To_Use) | out-null
- ## Change value no BIOS password
- $bios = Get-WmiObject -Namespace root/hp/instrumentedBIOS -Class HP_BIOSSettingInterface
- $bios.setbiossetting("Fast Boot", "Disable","") | out-null
- $bios.setbiossetting("Network (PXE) Boot", "Disable","") | out-null
- ## Change value with BIOS password
- $MyPassword = "password123456"
- $Password_To_Use = "<utf-16></utf>"+$MyPassword
- $bios = Get-WmiObject -Namespace root/hp/instrumentedBIOS -Class HP_BIOSSettingInterface
- $bios.setbiossetting("$MySetting", "$NewValue",$Password_To_Use) | out-null
- ## Change value from csv list
- $CSV_File = "D:\BIOS_Change.csv"
- $Get_CSV_Content = import-csv $CSV_File
- $bios = Get-WmiObject -Namespace root/hp/instrumentedBIOS -Class HP_BIOSSettingInterface
- ForEach($Settings in $Get_CSV_Content)
- {
- $MySetting = $Settings.Setting
- $NewValue = $Settings.Value
- $bios.setbiossetting("$MySetting", "$NewValue","") | out-null
- }
- ##Check settings changed
- $Execute_Change_Action = $bios.setbiossetting("$MySetting", "$NewValue","")
- $Change_Return_Code = $Execute_Change_Action.return
- If(($Change_Return_Code) -eq 0)
- {
- write-host "OK ==> New value for $MySetting is $NewValue"
- }
- Else
- {
- write-host "KO ==> Can not change setting $MySetting (Return code $Change_Return_Code)" -Foreground Yellow
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement