GetBIOS.psm1
<#
.Synopsis The Get-BIOS function allows you to list BIOS settings from your local or a remote Dell computer. You can query BIOS for the following manufacturer: Dell, HP, Lenovo, Toshiba .DESCRIPTION Allow you to list BIOS settings from your computer or a remote computer. You can query BIOS for the following manufacturer: Dell, HP, Lenovo, Toshiba -computer: List BIOS settings of a remote computer .EXAMPLE PS Root\> Get-BIOS The command above will list BIOS settings of your local computer .EXAMPLE PS Root\> Get-BIOS -Computer "Computer1" The command above will list BIOS settings of the remote computer called Computer1. It will prompt fro your credentials to access to the remote computer. .NOTES Author: Damien VAN ROBAEYS - @syst_and_deploy - http://www.systanddeploy.com #> function Get-Bios { [CmdletBinding()] Param( [Parameter(Mandatory=$false)] [string]$Computer ) Begin { Function Get_Dell_BIOS_Settings { $WarningPreference='silentlycontinue' If (Get-Module -ListAvailable -Name DellBIOSProvider) {} Else { Install-Module -Name DellBIOSProvider -Force } get-command -module DellBIOSProvider | out-null $Script:Get_BIOS_Settings = get-childitem -path DellSmbios:\ | select-object category | foreach { get-childitem -path @("DellSmbios:\" + $_.Category) | select-object attribute, currentvalue } $Script:Get_BIOS_Settings = $Get_BIOS_Settings | % { New-Object psobject -Property @{ Setting = $_."attribute" Value = $_."currentvalue" }} | select-object Setting, Value $Get_BIOS_Settings } 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" }} | select-object Setting, Value $Get_BIOS_Settings } Function Get_Lenovo_BIOS_Settings { $Script:Get_BIOS_Settings = gwmi -class Lenovo_BiosSetting -namespace root\wmi | select-object currentsetting | Where-Object {$_.CurrentSetting -ne ""} | select-object @{label = "Setting"; expression = {$_.currentsetting.split(",")[0]}} , @{label = "Value"; expression = {$_.currentsetting.split(",*;[")[1]}} $Get_BIOS_Settings } Function Get_Toshiba_BIOS_Settings { Try { $Script:Get_BIOS_Settings = Get-WmiObject -NameSpace "root\wmi" -Query "SELECT * FROM QueryBiosSettings" | % { New-Object psobject -Property @{ Setting = $_."CurrentSetting" Value = $_."Currentvalue" }} | select-object Setting, Value $Get_BIOS_Settings } Catch {} } If(($Computer -ne "")) { $Script:Creds = get-credential $scriptblock = {(Get-WmiObject Win32_Computersystem).manufacturer} $Get_manufacturer = Invoke-Command -ComputerName $Computer -ScriptBlock $scriptblock -credential $Creds } Else { $Get_manufacturer = (Get-WmiObject Win32_Computersystem).manufacturer } If($Get_manufacturer -like "*dell*") { $manufacturer = "Dell" } ElseIf($Get_manufacturer -like "*lenovo*") { $manufacturer = "Lenovo" } ElseIf(($Get_manufacturer -like "*HP*") -or ($Get_manufacturer -like "*hewlet*")) { $manufacturer = "HP" } ElseIf($Get_manufacturer -like "*toshiba*") { $manufacturer = "Toshiba" } Else { write-host "" write-host "########################################################" -Foreground yellow write-host " Your manufacturer is not supported by the module" -Foreground yellow write-host " Supported manufacturer: Dell, HP, Lenovo, Toshiba" -Foreground yellow write-host "########################################################" -Foreground yellow write-host "" break } } Process { write-host "" write-host "###################################################" -Foreground Cyan write-host " Your manufacturer is $manufacturer" -Foreground Cyan write-host "###################################################" -Foreground Cyan write-host "" switch ($manufacturer) { 'Dell' { If(($Computer -ne "")) { $Get_BIOS_Settings = Invoke-Command -credential $Creds -ComputerName $Computer -ScriptBlock ${Function:Get_Dell_BIOS_Settings} } Else { Get_Dell_BIOS_Settings } } 'HP' { Try { If(($Computer -ne "")) { $Get_BIOS_Settings = Invoke-Command -credential $Creds -ComputerName $Computer -ScriptBlock ${Function:Get_HP_BIOS_Settings} $Get_BIOS_Settings | select Setting, Value } Else { Get_HP_BIOS_Settings } } Catch {} } 'Lenovo' { Try { If(($Computer -ne "")) { $Get_BIOS_Settings = Invoke-Command -credential $Creds -ComputerName $Computer -ScriptBlock ${Function:Get_Lenovo_BIOS_Settings} $Get_BIOS_Settings | select Setting, Value } Else { Get_Lenovo_BIOS_Settings } } Catch {} } 'Toshiba' { Try { If(($Computer -ne "")) { $Get_BIOS_Settings = Invoke-Command -credential $Creds -ComputerName $Computer -ScriptBlock ${Function:Get_Toshiba_BIOS_Settings} $Get_BIOS_Settings | select Setting, Value } Else { Get_Toshiba_BIOS_Settings } } Catch {} } } } End { } } |