$Read1=Import-Csv"U:\reports\ad\test.csv"
$GetDepartment=$Read1.Department
$GetDesc=$Read1.DepartmentDesc
$GetMail=$Read1.email
foreach ($emailin$GetMail) { $email.remove($email.indexof("@"))}
$email
The above code works. I have 3 columns in my Excel CSV file, Department, DepartmentDesc & Email. The code above will strip off the @Acme.org from each email which is what I need. So I'm left with JonesSam instead of JonesSam@Acme.org
In Active Directory I have an OU created for each Department + DepartmentDesc. So it looks like this:
5023 Graphics
8305 Building Maintenance
But how do I compare cells in Excel? I need to do this:
If line two of my CSV file has 5023 Graphics JonesSam@Acme.org I need to move user JonesSam into the 5023 Graphics OU in AD.