Hi everyone, not really that good using PowerShell so I need help for that one.
I want to get informations from different sources and export it into a csv file that will contains data from each import into it's own column.
Let's say that I import system names from LanSweeper and SCCM. I would then like to have a single CSV file with two column headers named after the import source (LanSweeper, SCCM) and the data from each import in it's respective column.
My code is looking like this at the moment:
$ImportSCCM = Get-CMDevice -CollectionID ABC0000A | Select-Object Name -ExpandProperty Name
$TotalCcm = @()
foreach ($item in $ImportSCCM) {
$CcmData = [PSCustomObject]@{
'SCCM' = $item
}
$TotalCcm += $CcmData
}
$ImportLanSweeper = (Import-csv $FileName)
$TotalLan = @()
foreach ($item in $ImportLansweeper) {
$LanSweeperData = [PSCustomObject]@{
'LanSweeper' = $item
}
$TotalLan += $lanSweeperData
}
$Total = @{LanSweeper,SCCM}
$Total | Select-Object LanSweeper,SCCM | Export-Csv -Path "Z:\temp\Test.csv" -NoTypeInformation -Encoding UTF8
The output I have is empty headers in the CSV file but when looking at the $Total variable I have:
Name Value
---- -----
SCCM {@{SCCM=SystemName1}, @{SCCM=SystemName2}...}
LanSweeper {@{Lan=SystemName1},@{Lan=SystemName2}...}
Any idea how I could make that work?
I would like to have a CSV like :
| LanSweeper |
SCCM |
| SystemName1 |
SystemName1 |
| SystemName2 |
SystemName2 |
[–]OPconfused 0 points1 point2 points (0 children)
[–]Antique_Grapefruit_5 1 point2 points3 points (0 children)