Tuesday 1 June 2010

Get-Bios.ps1

  1. <# 
  2. .SYNOPSIS 
  3.     This script gets all the computers in a domain and then  
  4.     displays bios details for each one. 
  5. .DESCRIPTION 
  6.     This script uses the Active Directory module to get 
  7.     all computers. Then it enumerates this set and uses WMI 
  8.     to get bios information from each system. Note that  
  9.     script does not handle WMI errors. 
  10. .NOTES 
  11.     File Name  : Get-Bios.ps1 
  12.     Author     : Thomas Lee - tfl@psp.co.uk 
  13.     Requires   : PowerShell Version 2.0 
  14. .LINK 
  15.     This script posted to: 
  16.         http://pshscripts.blogspot.com/2010/06/get-biosps1.html
  17. .EXAMPLE 
  18.     PS [C:\FOO] .\Get-Bios.ps1 
  19.     Machine:           DC1.reskit.org 
  20.     Bios Name          BIOS Date: 03/19/09 22:51:32  Ver: 09.00.04 
  21.     Bios Manufacturer  American Megatrends Inc. 
  22.     Bios Version        
  23.     Bios Serial Number 3678-9986-1198-6272-1712-1835-12 
  24.   
  25.     Machine:           SQL1.reskit.org 
  26.     Bios Name          BIOS Date: 03/19/09 22:51:32  Ver: 09.00.04 
  27.     Bios Manufacturer  American Megatrends Inc. 
  28.     Bios Version        
  29.     Bios Serial Number 4769-0987-7689-7711-9784-0733-29 
  30.    <etc - rest snipped for brevity> 
  31. #> 
  32.  
  33. ## 
  34. # Start of Script 
  35. ## 
  36.  
  37. # Import the AD module 
  38. Import-Module activedirectory 
  39.  
  40. # Get the computers 
  41. $Computers = Get-ADComputer -Filter * 
  42.   
  43. # Visit each one and get some output 
  44. # NB: error handling should be added in for production use 
  45. foreach ($Computer in $Computers){ 
  46.     $bios = GWMI win32_bios -computer $computer.dnshostname 
  47.     "Machine:           {0}" -f $Computer.dnshostname 
  48.     "Bios Name          {0}" -f $BIOS.Name 
  49.     "Bios Manufacturer  {0}" -f $bios.manufacturer 
  50.     "Bios Version       {0}" -f $bios.SmbbiosBiosVersion 
  51.     "Bios Serial Number {0}" -f $bios.serialnumber 
  52.     "" 

No comments: