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
- win32_OperatingSystem :OS info
PS C:\> get-wmiobject win32_OperatingSystem –computername “servernm”
Or
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).
- Win32_PingStatus : Ping
- win32_quickfixengineering :Hot fix
- win32_Bios : #Bios information
- win32_Logicaldisk : #logical drives
- win32_Service :servicese
- win32_ComputerSystem
- 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:
- using –com
$xl = new-object -com Excel.Application
$wbk =”C:\abc.xls”
xl.Workbooks.open($wbk)
$xl.Cells.Item(1,1).Value()
….
$xl.Workbooks.Close()
And can update the xls cell.
Now to get the sql related information.
#————————-