I'm trying to write a simple powershell script to pull software and service data off a machine. So I'm trying to figure out the best way to consolidate the data onto one cvs file instead of two separate csv files. I wanted to use the below, but it would save time in the end for both sets of data to be combined.
Get-Services | Select StartType, Status, Name, DisplayName |
Export-CSV -path $servicescsv
Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* |
Select-Object DisplayName, DisplayVersion, Publisher, InstallDate |
Export-CSV -path $softwarecsv
So the above is probably quite simple, but I could just create two arrays for software and services. But then what is the best method to combine the two arrays without writing over each other? I know one of the issues is that DisplayName for software conflicts with DisplayName for services. So right now $array3 = $services + $software
only adds the software display name to the array, but the other columns are lost.
What is the best approach to this problem?