Created
January 21, 2019 15:23
-
-
Save kpatnayakuni/582fa08af9998afefc9cedf38e25e931 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$CSV1 = Import-Csv ".\CSV1.csv" | |
<# | |
Code UUID Asset | |
---- ---- ----- | |
DL1721 MNY07789-D112-E34C-B41D-4ACFB442B60P 23160 | |
HP1023 ABC07789-D112-E34C-B41D-4ACFB442B65D 23145 | |
HP2190 XYZ07789-D112-E34C-B41D-4ACFB442B65E 23146 | |
#> | |
$CSV2 = Import-Csv "C:\Windows\Temp\CSV2.csv" | |
<# | |
Code UUID Asset Tag | |
---- ---- --------- | |
HP2190 | |
HP1023 | |
HP1023 | |
HP1023 | |
DL1721 | |
HP2190 | |
HP2190 | |
HP1023 | |
#> | |
foreach($record in $CSV2) | |
{ | |
$found = $CSV1 | where {$_.Code -eq $record.Code} | |
$record.UUID, $record."Asset Tag" = $found.UUID, $found.Asset | |
} | |
return, $CSV2 | |
<# | |
Code UUID Asset Tag | |
---- ---- --------- | |
HP2190 XYZ07789-D112-E34C-B41D-4ACFB442B65E 23146 | |
HP1023 ABC07789-D112-E34C-B41D-4ACFB442B65D 23145 | |
HP1023 ABC07789-D112-E34C-B41D-4ACFB442B65D 23145 | |
HP1023 ABC07789-D112-E34C-B41D-4ACFB442B65D 23145 | |
DL1721 MNY07789-D112-E34C-B41D-4ACFB442B60P 23160 | |
HP2190 XYZ07789-D112-E34C-B41D-4ACFB442B65E 23146 | |
HP2190 XYZ07789-D112-E34C-B41D-4ACFB442B65E 23146 | |
HP1023 ABC07789-D112-E34C-B41D-4ACFB442B65D 23145 | |
#> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment