Tuesday, June 26, 2007

Software Inventory in a jiffy (Powershell)

WMIC and WSH are good enough to perform software inventory collection... but the coding's just a little bit longer...

Well to query wmi is not a big task, it's formatting the output that will get your code extra few lines of unnecessary vbtab's and vbcrlf's.

Install Windows Power Shell, then it will take only three (3) lines of codes to get it running and the output is as lovely as a well defined tabular echo's on your console.

Code Snippet:

  1. #Software Inventory
  2. $computer = "."
  3. $prod = Get-WmiObject -class "win32_product" -computer $computer
  4. $prod | sort name | ft Name, Version, Vendor, Installdate -a
Just save it as *.ps1 then execute it with powershell...

If at first you fail, call it version 1.0

No comments: