Author Posts

March 8, 2016 at 12:35 pm

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.

March 8, 2016 at 1:15 pm

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

March 8, 2016 at 1:20 pm

Change the -Path for your Export-CSV

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

March 8, 2016 at 3:50 pm

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.

March 9, 2016 at 9:14 am

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

March 10, 2016 at 7:47 am

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.

March 10, 2016 at 11:14 am

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.