11-24-2008
Downloads: 724
File size: 574 B
Views: 4,127
Embed
 |
Retrieve Inventory Information via WMI |
- function Get-ComputerInfo {
- param($computer = ".")
-
-
-
- $result = "" | Select-Object Model,Memory
-
-
-
- $result.Model = (Get-WmiObject win32_bios -computerName $computer).Manufacturer
- $result.Memory = (Get-WmiObject win32_operatingsystem -computerName $computer).TotalVisibleMemorySize
-
-
- $result
- }
-
- Get-ComputerInfo
demonstrates how you can retrieve pieces of computer information like model and memory and combine them in one new self-defined object variable. Based on this sample, you can expand inventory and include as many self-defined properties and fill them with as many pieces of information you want. Since all results are returned as one object, you can then export the object to XML, write it to disk, save it as CSV or do whatever else you want - the usual PowerShell object pipeline commands work with your resiult object just fine.