Powershell Day 27

Day 27 Inventory


As discussed ealier about wmi, wmi is a good for accessing inventory data from remote system as:

To get the Operating related information

  1. win32_OperatingSystem :OS info

PS C:\> get-wmiobject win32_OperatingSystem –computername “servernm”


PS C:\> get-wmiobject –Query “select name from win32_OperatingSystem” –computername

Where –Query is just like sql query where you can go with “Where” clause as well. And specifying –Computername from where you want to get the information(remote server).

  1. Win32_PingStatus : Ping
  2. win32_quickfixengineering :Hot fix
  3. win32_Bios : #Bios information
  4. win32_Logicaldisk : #logical drives
  5. win32_Service :servicese
  6. win32_ComputerSystem
  7. win32_PhysicalMemory : Memory

There are so many win32 options : List is here

Get-WmiObject -list | where {$_ -match “win32_*”}


This way we can get almost all the necessary information  about system. That can be exported into xls(csv) file usingExport-csv or export.txt

You can read the txt file using get-content cmdlet or read the sql server database using smo/.net/invoke-sqlcmd (shell).

Read the xls file:

  1. using –com

$xl = new-object -com Excel.Application

$wbk =”C:\abc.xls”






And can update the xls cell.

Now to get the sql related information.



This entry was posted in Powershell and tagged . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.