Every time i run my powershell script my output comes into a csv file but i want it to come all on one line, how it works now is that for every monitor my computer info sits infront of every monitor info like this:
but i just want my Nth monitorinfo to append behind the second one like this:
the code i use:
$output = foreach($computer in $Desktop){
ForEach ($Monitor in $Monitors){
$Manufacturer = ($Monitor.ManufacturerName -notmatch 0 | ForEach-Object{[char]$_}) -join ""
$Name = ($Monitor.UserFriendlyName -notmatch 0 | ForEach-Object{[char]$_}) -join ""
$Serial = ($Monitor.SerialNumberID -notmatch 0 | ForEach-Object{[char]$_}) -join ""
[PSCustomObject]@{
"Merk" = $Desktop.CsManufacturer
"Model" = $Desktop.CsModel
"S/n" = $Desktop | Select-Object -expand BiosSeralNumber
"PC Naam" = $Desktop.CsName
"CPU" = $processor.Name
"Memory" = "$RAM GB"
"OS" = $Desktop.WindowsProductName
"MAC LAN" = $MACLAN
"MAC WIFI" = $MACWIFI
"Office" = $officeVersion
"Merk /Model" = $Manufacturer
"Type" = $Name
"SerialScherm" = $Serial
}
}
}
$output | Export-Csv -Path $GL\info.csv -NoTypeInformation -Delimiter ';'
So if i would have 3 monitors the 3rd monitor would have to append after the 2nd now on the same line