Windows Vista Forums

Export-CSV Issues
  1. #1


    Ian_1 Guest

    Export-CSV Issues

    Im trying to export a list of users in an OU. However, with my script below:



    get-QADUser -SearchRoot 'ou=sales,OU=state,DC=domain,DC=net' | ft
    firstname,sn,displayname,mail,physicaldeliveryofficename | export-csv
    c:\scripts\Sales_Users.csv

    This is what is contained in the CSV:

    #TYPE Microsoft.PowerShell.Commands.Internal.Format.FormatStartData
    ClassId2e4f51ef21dd47e99d3c952918aff9cd,pageHeaderEntry,pageFooterEntry,autosizeInfo,shapeInfo,groupingEntry
    033ecb2bc07a4d43b5ef94ed5a35d280,,,,Microsoft.PowerShell.Commands.Internal.Format.TableHeaderInfo,
    9e210fe47d09416682b841769c78b8a3,,,,,
    27c87ef9bbda4f709f6b4002fa4af63c,,,,,
    27c87ef9bbda4f709f6b4002fa4af63c,,,,,
    27c87ef9bbda4f709f6b4002fa4af63c,,,,,
    27c87ef9bbda4f709f6b4002fa4af63c,,,,,
    27c87ef9bbda4f709f6b4002fa4af63c,,,,,
    27c87ef9bbda4f709f6b4002fa4af63c,,,,,
    and on and on>>>

    I even tried a " | Out-File sales.csv " -but received the same results.
    The command w/out the export on screen is perfect, so what am I doing wrong
    to export these?

      My System SpecsSystem Spec

  2. #2


    Brandon Shell [MVP] Guest

    Re: Export-CSV Issues

    Format-Table and Format-List output a different object type.

    If you are using export-csv you should use Select-Object instead of fromat-table

    Brandon Shell
    ---------------
    Blog: http://www.bsonposh.com/
    PSH Scripts Project: www.codeplex.com/psobject

    I> Im trying to export a list of users in an OU. However, with my script
    I> below:
    I>
    I> get-QADUser -SearchRoot 'ou=sales,OU=state,DC=domain,DC=net' | ft
    I> firstname,sn,displayname,mail,physicaldeliveryofficename | export-csv
    I> c:\scripts\Sales_Users.csv
    I>
    I> This is what is contained in the CSV:
    I>
    I> #TYPE Microsoft.PowerShell.Commands.Internal.Format.FormatStartData
    I>
    I> ClassId2e4f51ef21dd47e99d3c952918aff9cd,pageHeaderEntry,pageFooterEnt
    I> ry,autosizeInfo,shapeInfo,groupingEntry
    I>
    I> 033ecb2bc07a4d43b5ef94ed5a35d280,,,,Microsoft.PowerShell.Commands.Int
    I> ernal.Format.TableHeaderInfo,
    I>
    I> 9e210fe47d09416682b841769c78b8a3,,,,,
    I>
    I> 27c87ef9bbda4f709f6b4002fa4af63c,,,,,
    I>
    I> 27c87ef9bbda4f709f6b4002fa4af63c,,,,,
    I>
    I> 27c87ef9bbda4f709f6b4002fa4af63c,,,,,
    I>
    I> 27c87ef9bbda4f709f6b4002fa4af63c,,,,,
    I>
    I> 27c87ef9bbda4f709f6b4002fa4af63c,,,,,
    I>
    I> 27c87ef9bbda4f709f6b4002fa4af63c,,,,,
    I>
    I> and on and on>>>
    I>
    I> I even tried a " | Out-File sales.csv " -but received the same
    I> results. The command w/out the export on screen is perfect, so what
    I> am I doing wrong to export these?
    I>



      My System SpecsSystem Spec

Export-CSV Issues problems?

Similar Threads
Thread Thread Starter Forum Replies Last Post
Microsoft Works 9 calendar export as HTML issues dstalvey General Discussion 1 03 Jul 2009
Get-acl and export-csv agripnt PowerShell 3 17 Feb 2009
using export-csv to export to multiple CSV files Srinivas PowerShell 4 23 May 2008
Export to WAB? FiOS Dave Vista mail 4 22 Aug 2007
Export-CliXml/Export-Csv: Change to Export-Object? Alex K. Angelopoulos [MVP] PowerShell 3 04 Jun 2006