Parse Excel File via PowerShell for a loop

Hello everyone,

I would like to parse a column of one of my Excel file to retrieve the string that each of its cell can contain.
This will be used to set the appropriate value of the UPN of users in a specific OU in Active Directory.

The first column being the SAMAccountName and the second column the email address, I would like a loop that for each match of SAMAccountName it finds in the first column, it sets the value of associated row in the second column as its UPN.

I know already the Active Directory cmdlets I would have to use, they works but I do not succeed retrieving data  like I would like from the Excel file.

If someone could help me out on this that will be appreciated :)

Thanks a lot.

March 6th, 2014 5:35am

Hi Warrer,

the easiest way to do this, is to open the file in Excel and save it as a Csv file.
Then in PowerShell, use the Import-Csv command to get the content as objects.

Cheers,
Fred

Free Windows Admin Tool Kit Click here and download it now
March 6th, 2014 5:51am

That kind of answer my question yes indeed :)

It is much easier, thanks !

I would have prefer to avoid a file type change each time it is generated though :(
March 6th, 2014 11:38am

Hi,

This might help:

http://gallery.technet.microsoft.com/scriptcenter/7b2fdc8f-a528-4f19-b9ef-f5af349dc906

I haven't used this module myself, so I'm not sure how well it works.

Free Windows Admin Tool Kit Click here and download it now
March 6th, 2014 11:50am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics