I have a CSV that has two Columns a Computer and an action I also have another CSV that has 3 Columns Computer Identifier Serial Number and Device ID.
I want to take CSV1 and take Computer column and search for those values in CSV2 and see if its the computer identifier or serial and give me the matching device ID so I can run another function against that.
So CSV 1
Computer | Action |
---|---|
CB12345 | Lock |
574638 | Unlock |
Will Search through for where the computer value is in CSV 2
DeviceID | CB Number | Serial |
---|---|---|
57687348 | CB12345 | 674Z2X3 |
34554345 | CB65487 | 474Z2X3 |
54868323 | CB45789 | 574Z2X3 |
15593235 | CB65976 | 974Z2X3 |
37593236 | CB35466 | 074Z2X3 |
Once it finds the value whether it be a CB number or serial it will grab its corresponding Device ID so I can use that in another function.
This is what I had so far but I am not sure how to do it so I can use both CSVs
$yesterday = [datetime]::Today.AddDays(-1).tostring("yyyy-MM-dd")
$date = get-date -Format yyyy-MM-dd
$CB = import-csv -Path "\\Scripts\GAM test\CBs"
$GAM = import-csv -Path "\\Scripts\GAM\CSV\$yesterday-GAMprintCROSbasic.csv"
```
<# foreach ($record in $CB)
{
if ($record.action = "Unlock")
{
$DeviceID = $record.deviceID
$DeviceAsset = $record.asset
E:\gam\gam.exe update cros $DeviceID action enable
Write-Output "$deviceID is being disabled. $deviceasset"
Start-Sleep 10 #>