Announcement

Collapse
No announcement yet.

Output to different column in excel csv

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Output to different column in excel csv

    Hi all

    Im looking to out put information into an excel sheet or csv file. I need to export the 1st query to column 1 and the second to column 2.

    Its only really practical if this command is only a few lines long.

    So far ive tried export-csv, write-output and more but cant get the data on separate columns

    my best effort so far

    Get-ADUser -filter * -SearchBase "ou=users,dc=contoso,dc=com" | select samaccountname,givenname,surname >> C:\ps-get-user-data.csv


    will put all the data into 1 column and 1 cell. I need the data on separate columns. e.g. a1,b1,c1 with excel


    Anyone in the know


    Thanks


    Confuseis



  • #2
    Re: Output to different column in excel csv

    There is an "Export-CSV" cmdlet which should do what you want, so:

    Get-ADUser -filter * -SearchBase "ou=users,dc=contoso,dc=com" | select samaccountname,givenname,surname | Export-CSV <filename>

    Full syntax: http://technet.microsoft.com/en-us/l.../hh849932.aspx
    Tom Jones
    MCT, MCSE (2000:Security & 2003), MCSA:Security & Messaging, MCDBA, MCDST, MCITP(EA, EMA, SA, EDA, ES, CS), MCTS, MCP, Sec+
    PhD, MSc, FIAP, MIITT
    IT Trainer / Consultant
    Ossian Ltd
    Scotland

    ** Remember to give credit where credit is due and leave reputation points where appropriate **

    Comment


    • #3
      Re: Output to different column in excel csv

      Thanks Ossian that works perfectly. I was making the mistake of | export-csv >> <filename>
      Last edited by confuseis; 20th March 2014, 19:01.

      Comment


      • #4
        Re: Output to different column in excel csv

        Glad to help!
        Tom Jones
        MCT, MCSE (2000:Security & 2003), MCSA:Security & Messaging, MCDBA, MCDST, MCITP(EA, EMA, SA, EDA, ES, CS), MCTS, MCP, Sec+
        PhD, MSc, FIAP, MIITT
        IT Trainer / Consultant
        Ossian Ltd
        Scotland

        ** Remember to give credit where credit is due and leave reputation points where appropriate **

        Comment

        Working...
        X