Get-WMIabc


.NAME       : Get-WMIabc

.VERSION       : 1.3

.LAST UPDATED       : 2/24/2013
Fixed help --- help Get-WMIabc -full -- now functional.  (1.1)
Changed Write-Host to Write-Output -- Better way to display 'date' information.  (1.2)
Script is AllSigned ready -- Only scripts signed by a trusted publisher can be run.  (1.3)

.AUTHOR       : J. Perry Stonne

.LINK       : http://www.twitter.com/webstonne

.COMMENTS      : This script is based on a template created by Don Jones.
                           (Turn PowerShell Commands into Reusable CLI and GUI Tools)

.LINK      : Don Jones Video - Channel 9 - TechEd North America 2012


* Do Not Use In A Production Environment Until You Have Tested *
* Thoroughly In A Secure Lab Environment. *
* Use At Your Own Risk. *




Function Get-WMIabc {
<#
.SYNOPSIS
 This script retrieves WMI information from one or several machines. It converts three dates into readable form:
  Last Boot Time, BIOS Release Date, OS Installation Date.
.DESCRIPTION
This script uses Windows Management Instrumenatation (WMI) to retrieve information from one or several machines
using the ComputerName parameter or an IP Address.
.PARAMETER ComputerName
Standard parameter
.EXAMPLE
Get-WMIabc | Get-Content "M:\computer.txt"
This will use a text list of several machines to query
.EXAMPLE
Get-WMIabc | Get-Content "M:\computer.csv"
This will use a comma seperated value spreadsheet (Excel) of several machines to query
.EXAMPLE
Get-WMIabc -ComputerName JoeComputer
Query single machine
.EXAMPLE
Get-WMIabc -ComputerName 51.80.37.212
Query machine using IP address
.EXAMPLE
Get-WMIabc -ComputerName 51.80.37.212, JoeComputer
Query Two (or more) machines
#>

[CmdLetBinding()]
param(
   [Parameter(Mandatory=$True,ValueFromPipeline=$True)]
   [string[]]$ComputerName
)
BEGIN{}
PROCESS {
  foreach ($computer in $ComputerName) {
     $os = Get-WMIObject -Class Win32_OperatingSystem -ComputerName $computer
     $time = $os.LastBootUpTime
     $bios = Get-WMIObject -Class Win32_Bios -ComputerName $computer
     $cs = Get-WMIObject -Class Win32_ComputerSystem -ComputerName $computer
     $props = @{'ComputerName'=$computer;
          'OSVersion'=$os.version;
          'SPVersion'=$os.servicepackmajorversion;
    'OSSerialNumber'=$os.SerialNumber;
    'OperatingSystemSKU'=$os.OperatingSystemSKU;
    'BIOSSerial'=$bios.serialnumber;
    'Description'=$bios.Description;
          '__SERVER'=$bios.PSComputerName;
          'Model'=$cs.model;
          'Manufacturer'=$cs.manufacturer
           }
   
          $obj = New-Object -TypeName PSObject $props

     Write-OutPut $obj
     Write-Output " "
     Write-Output "Last Boot Time"
     [System.Management.ManagementDateTimeconverter]::ToDateTime($time)
     Write-Output "BIOS Release Date"
     [Management.ManagementDateTimeConverter]::ToDateTime($bios.ReleaseDate)
     Write-Output "OS Installation Date"
     [System.Management.ManagementDateTimeconverter]::ToDateTime($os.InstallDate)

}
}
END{}
}


Resume J. Perry Stonne