Hello Everyone!
First off, please note that I am self-taught when it comes to Powershell, so please forgive me if my question seems obvious.
I am trying to gather some system information using the following script(and again, my apologies for literally copying/pasting the script into the thread):
$exportLocation = ‘C:\Users\Nik\Documents\pcInventory2.csv’
$Bios = Get-WmiObject win32_bios
$hardware = Get-WmiObject win32_computersystem
$sysbuild = Get-WmiObject win32_wmiSetting
$OS = Get-WmiObject win32_OperatingSystem
$networks = Get-WmiObject win32_NetworkAdapterConfiguration | Where-Object {$. IPEnabled}
$drivespace = Get-WmiObject win32_volume -Filter ‘drivetype = 3’ |
Select-Object PScomputername, driveletter | Where-Object { $.driveletter -match ‘C:’ }
$cpu = Get-WmiObject win32_Processor
$username = Get-ChildItem “C:\Users” | Sort-Object LastWriteTime -Descending | Select-Object name, LastWriteTime
$totalMemory = [math]::round($hardware.TotalPhysicalMemory/1024/1024/1024, 2)
$lastBoot = $OS.ConvertToDateTime($OS.LastBootUpTime)
$IPAddress = $networks.IpAddress[0]
$MACAddress = $networks.MACAddress
$systemBios = $Bios.serialnumber
$outputObj = New-Object -Type PSObject
$outputObj | Add-Member -MemberType NoteProperty -Name Manufacture -Value $Hardware.Manufacture
$outputObj | Add-Member -MemberType NoteProperty -Name Model -Value $Hardware.Model
$outputObj | Add-Member -MemberType NoteProperty -Name Processor_Type -Value $cpu.Name
$outputObj | Add-Member -MemberType NoteProperty -Name System_Type -Value $hardware.SystemType
$outputObj | Add-Member -MemberType NoteProperty -Name Operating_System -Value $OS.Caption
$outputObj | Add-Member -MemberType NoteProperty -Name Operating_System_Version -Value $OS.version
$outputObj | Add-Member -MemberType NoteProperty -Name Operating_System_BuildVersion -Value$sysbuild.BuildVersion
$outputObj | Add-Member -MemberType NoteProperty -Name Serial_Number -Value $systemBios
$outputObj | Add-Member -MemberType NoteProperty -Name IP_Address -Value $IPAddress
$outputObj | Add-Member -MemberType NoteProperty -Name MAC_Address -Value $MACAddress
$outputObj | Add-Member -MemberType NoteProperty -Name Last-User -Value $username.Name
$outputObj | Add-Member -MemberType NoteProperty -Name User_Last_Login -Value $username.LastWriteTime
$outputObj | Add-Member -MemberType NoteProperty -Name C:_FreeSpace_GB -Value $drivespace.GBfreespace
$outputObj | Add-Member -MemberType NoteProperty -Name Total_Memory_GB -Value $totalMemory
$outputObj | Add-Member -MemberType NoteProperty -Name Last_ReBoot -Value $lastboot
$outputObj | Export-Csv $exportLocation -Append -NoTypeInformation
When I export this into a CSV file, I get most of the information, except for: Processor_Type, Last_User and Last_User_Login. These display as system.object.
Can anyone help me resolve this?
Thank you!