Parse Excel File via PowerShell for a loop RRS feed

  • Question

  • 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.

    Thursday, March 6, 2014 10:30 AM


  • 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.


    There's no place like

    • Proposed as answer by jrv Thursday, March 6, 2014 10:49 AM
    • Marked as answer by Warrer5 Thursday, March 6, 2014 4:37 PM
    Thursday, March 6, 2014 10:46 AM

All replies