My current Powershell script spits out a .txt doc of the computer name, and software that I would like to be able to import into a csv file, with each computer name being a new column.
currently the output looks like this:
PC1=
productname
SoftwareA
SoftwareB
PC2=
productname
SoftwareA
SoftwareB
how can I script this to appropriately sort this data? a straight import to csv will have all of this info in a single column. Is there something I can throw on the foreach loop to have it write to the next column? Or could I have each loop write to it's own .txt, and then grab each .csv and have them import into a new sheet
here's the source code:
$ComputerNames = get-content ".\Computers.txt"
foreach ($Computer in $ComputerNames)
{$arryStandardSoftware = get-content -path ".\StandardSoftware.txt"| Foreach-Object{$_.trim()}
$AuditResult = (Get-WMIObject -namespace "root\cimv2\sms" -class sms_installedsoftware -computername "$computer"|
Select-Object productname|Where-Object{$arryStandardSoftware -notcontains "$($_.productname)"})
echo "$Computer ="$AuditResult | out-file ".\SoftwareAudit.txt" -append}