2

General Information

$ComputerSystem = Get-WmiObject -Class Win32_ComputerSystem | Select -Property Model , Manufacturer , Description , PrimaryOwnerName , SystemType

Boot Configuration

$BootConfiguration = Get-WmiObject -Class Win32_BootConfiguration | Select -Property Name , ConfigurationPath 

BIOS Information

$BIOS = Get-WmiObject -Class Win32_BIOS | Select -Property PSComputerName , Manufacturer , Version #| Export-Csv -InputObject 

Operating System Information

$OS = Get-WmiObject -Class Win32_OperatingSystem | Select -Property Caption , CSDVersion , OSArchitecture , OSLanguage  

I want to export all these variables to a csv file with headings but I am unable to.

3
  • Create a custom object that contains all properties you want in your csv file and pipe it to export-csv like kohlbrr suggests Commented Nov 11, 2014 at 17:55
  • Think about the structure of the CSV file you want - it will make things clearer (write down an example file manually with the column headings and sample content). Commented Nov 11, 2014 at 20:01
  • Two of your variables have a Manufacturer property. Commented Nov 11, 2014 at 20:18

1 Answer 1

2

The following combines the noteproperties from each object created separately by the get-wmiobject commands to the $report variable. From there you can export to csv.

This could be better simplified with loops that go through each variable created by the gwmi calls and add the noteproperties to the report variable.

$ComputerSystem = Get-WmiObject -Class Win32_ComputerSystem | Select -Property Model , Description , PrimaryOwnerName , SystemType
$BootConfiguration = Get-WmiObject -Class Win32_BootConfiguration | Select -Property Name , ConfigurationPath 
$BIOS = Get-WmiObject -Class Win32_BIOS | Select -Property PSComputerName , Manufacturer , Version 
$OperatingSystem = Get-WmiObject -Class Win32_OperatingSystem | Select -Property Caption , CSDVersion , OSArchitecture , OSLanguage  

$report = New-Object psobject
$report | Add-Member -MemberType NoteProperty -name Model -Value $ComputerSystem.Model
$report | Add-Member -MemberType NoteProperty -name Description -Value $ComputerSystem.Description
$report | Add-Member -MemberType NoteProperty -name PrimaryOwnerName -Value $ComputerSystem.PrimaryOwnerName
$report | Add-Member -MemberType NoteProperty -name SystemType -Value $ComputerSystem.SystemType
$report | Add-Member -MemberType NoteProperty -name Name -Value $BootConfiguration.Name
$report | Add-Member -MemberType NoteProperty -name ConfigurationPath -Value $BootConfiguration.ConfigurationPath
$report | Add-Member -MemberType NoteProperty -name PSComputerName -Value $BIOS.PSComputerName
$report | Add-Member -MemberType NoteProperty -name Manufacturer -Value $BIOS.Manufacturer
$report | Add-Member -MemberType NoteProperty -name Version -Value $BIOS.Version
$report | Add-Member -MemberType NoteProperty -name Caption -Value $OS.Caption
$report | Add-Member -MemberType NoteProperty -name CSDVersion -Value $OS.CSDVersion
$report | Add-Member -MemberType NoteProperty -name OSArchitecture -Value $OS.OSArchitecture
$report | Add-Member -MemberType NoteProperty -name OSLanguage -Value $OS.OSLanguage

$report | export-csv .\file.csv -NoTypeInformation
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.