Skip to content

Instantly share code, notes, and snippets.

@kpatnayakuni
Last active January 18, 2019 13:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kpatnayakuni/ba1d1ec656a7de85d41d6bc31f9e9210 to your computer and use it in GitHub Desktop.
Save kpatnayakuni/ba1d1ec656a7de85d41d6bc31f9e9210 to your computer and use it in GitHub Desktop.
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