Announcement

Collapse
No announcement yet.

Output to different column in excel csv

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

  • confuseis
    started a topic Output to different column in excel csv

    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



  • Ossian
    replied
    Re: Output to different column in excel csv

    Glad to help!

    Leave a comment:


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

    Leave a comment:


  • Ossian
    replied
    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

    Leave a comment:

Working...
X