Export-CSV Issue Maybe

Tagged: 

This topic contains 6 replies, has 3 voices, and was last updated by Profile photo of Matt Bloomfield Matt Bloomfield 6 months, 3 weeks ago.

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #36285
    Profile photo of Jamie Hughes
    Jamie Hughes
    Participant

    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
    Profile photo of Matt Bloomfield
    Matt Bloomfield
    Participant

    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
    Profile photo of Bob McCoy
    Bob McCoy
    Participant

    Change the -Path for your Export-CSV

    $(join-path -path $env:UserProfile -ChildPath \Desktop\VoiceRoute.csv)
    #36294
    Profile photo of Jamie Hughes
    Jamie Hughes
    Participant

    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
    Profile photo of Matt Bloomfield
    Matt Bloomfield
    Participant

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

    #36384
    Profile photo of Jamie Hughes
    Jamie Hughes
    Participant

    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
    Profile photo of Matt Bloomfield
    Matt Bloomfield
    Participant

    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.

Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.