Advertisement
Guest User

Untitled

a guest
Jun 14th, 2023
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.82 KB | None | 0 0
  1. ## Related post http://www.systanddeploy.com/2019/03/list-and-change-bios-settings-with.html
  2. Function Get_HP_BIOS_Settings
  3. {
  4. $Script:Get_BIOS_Settings = Get-WmiObject -Namespace root/hp/instrumentedBIOS -Class hp_biosEnumeration -ErrorAction SilentlyContinue | % { New-Object psobject -Property @{
  5. Setting = $_."Name"
  6. Value = $_."currentvalue"
  7. Available_Values = $_."PossibleValues"
  8. }} | select-object Setting, Value, Available_Values
  9. $Get_BIOS_Settings
  10. }
  11.  
  12. $Z = Get_HP_BIOS_Settings
  13. $z | ? {$_.Setting -in ("Remote Wakeup Boot Source","S5 Maximum Power Savings")}
  14.  
  15. ## Is password set
  16. $IsPasswordSet = Get-WmiObject -Namespace root/hp/instrumentedBIOS -Class HP_BIOSSettingInterface
  17. If($IsPasswordSet -eq 1){write-host "Password is configured"}Else{write-host "No BIOS password"}
  18.  
  19. ## Enabled WOL no BIOS password
  20. $bios = Get-WmiObject -Namespace root/hp/instrumentedBIOS -Class HP_BIOSSettingInterface
  21. $bios.setbiossetting("Remote Wakeup Boot Source", "Remote Server","") | out-null
  22. $bios.setbiossetting("S5 Maximum Power Savings", "Disable","") | out-null
  23.  
  24. ## Enable with BIOS password
  25. $MyPassword = "password123456"
  26. $Password_To_Use = "<utf-16></utf>"+$MyPassword
  27. $bios = Get-WmiObject -Namespace root/hp/instrumentedBIOS -Class HP_BIOSSettingInterface
  28. $bios.setbiossetting("$MySetting", "$NewValue",$Password_To_Use) | out-null
  29. $bios.setbiossetting("Remote Wakeup Boot Source", "Remote Server", $Password_To_Use) | out-null
  30. $bios.setbiossetting("S5 Maximum Power Savings", "Disable", $Password_To_Use) | out-null
  31.  
  32. ## Change value no BIOS password
  33. $bios = Get-WmiObject -Namespace root/hp/instrumentedBIOS -Class HP_BIOSSettingInterface
  34. $bios.setbiossetting("Fast Boot", "Disable","") | out-null
  35. $bios.setbiossetting("Network (PXE) Boot", "Disable","") | out-null
  36.  
  37. ## Change value with BIOS password
  38. $MyPassword = "password123456"
  39. $Password_To_Use = "<utf-16></utf>"+$MyPassword
  40. $bios = Get-WmiObject -Namespace root/hp/instrumentedBIOS -Class HP_BIOSSettingInterface
  41. $bios.setbiossetting("$MySetting", "$NewValue",$Password_To_Use) | out-null
  42.  
  43. ## Change value from csv list
  44. $CSV_File = "D:\BIOS_Change.csv"
  45. $Get_CSV_Content = import-csv $CSV_File
  46. $bios = Get-WmiObject -Namespace root/hp/instrumentedBIOS -Class HP_BIOSSettingInterface
  47. ForEach($Settings in $Get_CSV_Content)
  48. {
  49. $MySetting = $Settings.Setting
  50. $NewValue = $Settings.Value
  51. $bios.setbiossetting("$MySetting", "$NewValue","") | out-null
  52. }
  53.  
  54. ##Check settings changed
  55. $Execute_Change_Action = $bios.setbiossetting("$MySetting", "$NewValue","")
  56. $Change_Return_Code = $Execute_Change_Action.return
  57. If(($Change_Return_Code) -eq 0)
  58. {
  59. write-host "OK ==> New value for $MySetting is $NewValue"
  60. }
  61. Else
  62. {
  63. write-host "KO ==> Can not change setting $MySetting (Return code $Change_Return_Code)" -Foreground Yellow
  64. }
  65.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement