Reputation: 11
Get-WmiObject -Class Win32_ComputerSystem; -Class Win32_Bios -ComputerName computer001, computer002 | Name, Caption, Identifyingnumber, vendor, UserName Export-CSV ComputerList.csv
Is what I have so far. I am trying to get this type of output
Model: OptiPlex 760
Name: Computer006
UserName: Domain\UserName
SerialNumber: M4RQFQZ
If it can be exported into excel with headers, that would be great too. I have 10 remote stores I need to run this for.
Upvotes: 1
Views: 415
Reputation: 54981
You need to use one Get-WmiObject
-call per WMI class and create a custom object with the combined data. Ex:
#$servers = "computer001", "computer002"
$servers = "localhost", "localhost" #test
$servers | ForEach-Object {
$CS = Get-WmiObject -Class Win32_ComputerSystem -ComputerName $_
$BIOS = Get-WmiObject -Class Win32_Bios -ComputerName $_
New-Object -TypeName psobject -Property @{
Model = $CS.Model
Name = $CS.Name
UserName = $CS.UserName
SerialNumber = $BIOS.SerialNumber
}
}
UserName Name Model SerialNumber
-------- ---- ----- ------------
FRODEPC\Frode FRODEPC System Product Name System Serial Number
FRODEPC\Frode FRODEPC System Product Name System Serial Number
You could use pipe it through Format-List Model, Name, UserName, SerialNumber
to get a list-view, but I won't work if you want to export it (to export, pipe it directly to Export-CSV ...
)
Model : System Product Name
Name : FRODEPC
UserName : FRODEPC\Frode
SerialNumber : System Serial Number
Model : System Product Name
Name : FRODEPC
UserName : FRODEPC\Frode
SerialNumber : System Serial Number
As you can see I have a custom built computer, but it should display proper model and serialnumber values for a prebuilt OEM-machine.
Upvotes: 3