I have been looking at different post and articles but cant figure out how to go through a CSV file line by line and when it see a name in lets say column F it then writes a new name in column J. I will have different names in column F that I want to write out in column J. This is what I have so far but can seem to figure out how to proceed.
A B C D E F G H
Machine Type OS name Owner Tag Name Publisher Version
Com1 srv Windows bob 123 Windows 2016 Microsoft 2016
Com2 srv Linux Jake 456 Linux Redhat 6.2
$csv = Get-ChildItem -Path “C:\temp\Landesk Server Software Inventory*.csv”
$modifiedcsv = @()
$importcsv = Import-Csv $csv
# loop though rows
foreach ($row in $importcsv) {
#? Create logic to lookup $row.column name in your lookup table for common names
If ($row.Type0 -eq 'Windows*') {
$row."Name" = "$($row.name)"
Write-Host $row."Microsoft Windows 2016 Standard".Range(k1:k1)
} Else {
}
$row | Add-Member -MemberType NoteProperty -Name "Common Name" -Value $commonname -PassThru
$emptyhash += $row
If ($row.Type0 -eq 'Linux*') {
$row."Name" = "$($row.name)"
Write-Host $row."Redhat".Range(k1:k1)
} Else {
}
$row | Add-Member -MemberType NoteProperty -Name "Common Name" -Value $commonname -PassThru
$emptyhash += $row
}
$modifiedcsv | Export-csv -nti $filename