I've got a bunch of csv files that each look like this:
DD-L-1_test.jaun.Csv
Parameter, Version, Status
OS, 21H2, Compliant
Chrome, 107.1.1, Compliant
DD-L-2_test.smith.Csv
Parameter, Version, Status
OS, 21H2, Compliant
Chrome, 107.1.1, Non-Compliant
The output I'd like is:
PCName, username, OS, Chrome
DD-L-1, test.jaun, Compliant, Compliant
DD-L-2, test.smith, Compliant, Non-Compliant
I've attempted the following solution:
$Results = Get-ChildItem $destPath -Recurse -Include '*.csv' -Force | ForEach-Object {
$Object = [PSCustomObject]@{
PCName = $_.BaseName
}
Import-Csv -Path $_.FullName | ForEach-Object {
$Object | Add-Member -MemberType NoteProperty -Name $_.Parameter -Value $_.Status -Force
}
$Object
}
However, this did not work because unable to create username name column with csv file name only with test.jaun