Export-CSV Issue Maybe

This topic contains 6 replies, has 3 voices, and was last updated by  Matt Bloomfield 2 years, 3 months ago.

  • Author
  • #36285

    Jamie Hughes

    Trying to use Export-CSV and the output includes the return type instead of the value.

     Get-CsVoiceRoute | select-object Name,Identity,PstnGatewayList,Description,Priority,NumberPattern,PstnUsages,SuppressCallerId,AlternateCallerId |export-csv $env:UserProfile\Desktop\VoiceRoute.csv 

    The "PstnGatewayList" value is replaced by the item type during the export. Hoping there is a work around.

    Found that the item I am trying to return is a collection, now to get that collection to output.

    PS. this is a Lync cmdlet
    PSS. I'm a PS novice.

  • #36286

    Matt Bloomfield

    Boe Prox has a good article on how to deal with this: learn-powershell.net.

    Your select will need to be
    select-object Name,Identity,@{l='PstnGatewayList';e={$_.PstnGatewayList -join ','}},Description,Priority,NumberPattern,PstnUsages,SuppressCallerId,AlternateCallerId

  • #36287

    Bob McCoy

    Change the -Path for your Export-CSV

    $(join-path -path $env:UserProfile -ChildPath \Desktop\VoiceRoute.csv)
  • #36294

    Jamie Hughes

    Thank you guys.

     select-object Name,Identity,@{l='PstnGatewayList';e={$_.PstnGatewayList -join ','}},Description,Priority,NumberPattern,PstnUsages,SuppressCallerId,AlternateCallerID 

    I modified this one and it works great expect for one. When I use the cmdlet get-cstopology, and I use

    @{Name='InternalDomains';Expression={[string]::join(“;”, ($_.InternalDomains))}}

    it fails to return the values.

  • #36321

    Matt Bloomfield

    Syntax looks OK. Are you sure InternalDomains isn't an empty collection?

  • #36384

    Jamie Hughes

    I am sure, it has two results, however the output returns the object class (if I am saying that right) rather than the results. The difference seems to be the export. If I comment out the export I get the result.

  • #36395

    Matt Bloomfield

    I wonder if you have a problem with nested collections. I.e. the objects in the InternalDomains collection are themselves collections and/or those collections also have nested collections.

    Try piping to Get-Member to investigate.

    I think your best bet is going to be to create a custom object with all the properties you're after and then export your custom object to the CSV file.

You must be logged in to reply to this topic.