troubleshooting Question

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

Avatar of Aakash Aggarwal
Aakash Aggarwal asked on
PowershellActive Directory
4 Comments3 Solutions95 ViewsLast Modified:
$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] = $_}
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 3 Answers and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 3 Answers and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros