I'm basically trying to extract data from the Windows physical machine, I need all 4 classes to achieve the required data. If I take $SysSummary variable in my terminal it outputs the data from all 4 variables. However when exporting to CSV only the first addition to the array is present. Can anyone suggest how I can get all this data into a CSV and nicely formatted?
Thank you.
#Path variable that can be edited to appropriate location
$sysinfopath = 'PATHGOESHERE'
#Assign our required classes for the system details to a variable for easier access in our compiler.
$SysInfo = Get-CimInstance -ClassName Win32_ComputerSystem
$SysProcessor = Get-CimInstance -ClassName Win32_Processor
$SysDisk = Get-CimInstance -ClassName Win32_DiskDrive
$SysBios = Get-CimInstance -ClassName Win32_BIOS
# Compile the $SysInfo class data into our final summary variable.
$SysSummary = @($SysInfo | Select-Object @{N='Computer Name';E={$SysInfo.Name}}, @{N='Domain Name';E={$SysInfo.Domain}},@{N='Manufacturer';E={$SysInfo.Manufacturer}}, @{N='Model';E={$SysInfo.Model}}, @{N='Memory (GB)';E={[math]::Round($SysInfo.TotalPhysicalMemory/ 1GB)}})
# Compile the $SysProcessor class data into our final summary variable.
$SysSummary += $SysProcessor | Select-Object @{N='CPU Name';E={$SysProcessor.Name}}, @{N='Core Count';E={$SysProcessor.NumberOfCores}}
# Compile the $SysDisk class data into our final summary variable.
$SysSummary += $SysDisk | Select-Object @{N='Serial No';E={$SysDisk.Model}}, @{N='Storage Size';E={[math]::Round($SysDisk.Size/ 1GB)}}
# Compile the $SysBios class data into our final summary variable.
$SysSummary += $SysBios | Select-Object @{N='Serial No';E={$SysBios.SerialNumber}}
# Export the $SysSummary variable to a CSV, path is set on line 25
$SysSummary | Export-Csv -path $sysinfopath