Avatar of Aakash Aggarwal
Aakash Aggarwal
 asked on

Need to match 6 digits with 5 digits where just 0 is extra

$UserList = Import-Csv -Path "j:\testad.csv"
$UserData = Import-Csv -Path "j:\testswn.csv"
$Lookup = @{}
$UserData | ForEach-Object {$Lookup[$_.EmployeeID] = $_}
$UserList | Select-Object -Property `
      EmployeeID, Givenname, sn, EmailAddress, StreetAddress, City, State, Country, PostalCode, `
      @{n='Telephone'; e={$Lookup[$_.EmployeeID].Telephone}}, @{n='PersonalEmail'; e={$Lookup[$_.EmployeeID].PersonalEmail}} |
      Export-Csv -NoTypeInformation -Path "j:\testresult2.csv"


Everything is fine but the thing is in one CSV file for some Employees id they are in 6 digits and others in 5 digits, so there the matching result we are getting is incorrect.

Ex- If in my first CSV there are 2 records of Employee id - 123456, 034567 where as in second CSV file it is like- 123456, 34567(0 is not there), so how can we change the equate equation for employee ids so that we can match 6 digits employee id with 5 digits in second csv?

$UserData | ForEach-Object {$Lookup[$_.EmployeeID] = $_}
PowershellActive Directory

Avatar of undefined
Last Comment
Jose Gabriel Ortega Castro

8/22/2022 - Mon
SOLUTION
Jose Gabriel Ortega Castro

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
ASKER CERTIFIED SOLUTION
footech

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
SOLUTION
aikimark

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Jose Gabriel Ortega Castro

answered
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck