Quantcast
Channel: PowerShell
Viewing all articles
Browse latest Browse all 15370

Output List in Existing CSV comparing the two CSVs

$
0
0

I am trying to enter data into one csv. The datais a result of the comparison between the two csvs.

For Example:

CSV 1 says

Text
Host TypeHost1 ServerHost2 SwitchHost3 HubHost4 Router

CSV 2 says:

Text
List of Types Hosts Host1 random letters Host2 random letters Host3 Host2 Host4 Host3 Host2


The output should be

Text
List of Types Hostsserver switch Host1 random letters Host2hub switch random letters Host3 Host2router hub switch Host4 Host3 Host2


This is what I have:

My problem seems to be the comparison part

Powershell
$CSV1=Import-Csv"Pathname"Foreach($titlein$CSV1){$Hosts=$title."Host"$Type=$title."Type"}$csv2=Import-Csv"Pathname"foreach($titlein$CSV2){$Typelist=$title."List of Types"$Hostlist=$title."Host"if($Hostlist-contains$Host){$title.'List of Types'=$Type}}


Viewing all articles
Browse latest Browse all 15370

Latest Images

Trending Articles



Latest Images