Last active
January 18, 2019 13:02
-
-
Save kpatnayakuni/ba1d1ec656a7de85d41d6bc31f9e9210 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
function Update-SystemType | |
{ | |
$Mastercsv = Import-Csv "C:\Windows\Temp\CSV1.csv" | |
$Productinfo = Import-Csv "C:\Windows\Temp\CSV2.csv" | |
foreach($record in $Mastercsv) | |
{ | |
$SysType = ($Productinfo | where {$_.Code -eq $record.code}).type | |
if ([string]::IsNullOrEmpty($SysType)) | |
{ | |
$sysType = 'Unknown, due to non-matching code' | |
} | |
$record.LaptopDesktop = $SysType | |
} | |
Return, $Mastercsv | |
} | |
<# | |
PS C:\> Update-SystemType | Format-Table | |
Computer Product Code Country Department LaptopDesktop | |
-------- ------- ---- ------- ---------- ------------- | |
Com1 EliteDesk 705 HP2190 AU FN D | |
Com2 EliteBook 830 HP1023 AU IT L | |
Com3 EliteBook 830 HP1023 FR FN L | |
Com4 Zbook 15U HP2020 IN FN L | |
Com5 OptiPlex 3010 DL1721 FR FN D | |
#> | |
Update-SystemType | ConvertTo-Csv | Out-File -FilePath "C:\Windows\Temp\CSV3.csv" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment