CLI Powershell help

I'm looking to export the callroutes to a csv, to get a spreadsheet of ultimately the DNIS numbers and Operating Schedules associated with that DID.

What I have so far (gcl is an alias for gc.exe)

(gcl architect ivrs list | ConvertFrom-Json) | Select-Object id, name, state, flowId, @{Name="ScheduleGroupName"; Expression={$_.scheduleGroup.name}}, dnis

And this is all well and good, except dnis is an object and doesn't export to csv. ie the values are just System.Object[]

My powershell-fu is not very strong, and so i'm just looking to get all the dnis numbers as comma/pipe separated values in to that export, the googling I've done has not helped get me any closer so any help would be appreciated.

Hello,

The "dnis" attribute you get back is an array of string.
(this is likely why you get "System.Object[]" - array of System.Object - printed).

So you'll need to convert that array of strings to a string. As you are already using "," as the separator for your csv, you'd need to use something else (like ";" maybe - if ever one of your IVR configuration has more than one dnis set).
I am not familiar with PowerShell - I don't have a Windows PC...
But found this doing a search on internet, to convert an array to a string with separator (assuming $array is the array...): $array -join ';'

Regards,

Thanks Jerome,

I got this going eventually, so posting here for anyone else who needs the same help:

Where gcl is an alias for gc.exe
(gcl architect ivrs list | ConvertFrom-Json) | Select-Object id, name, state, flowId, @{Name="ScheduleGroupName"; Expression={$.scheduleGroup.name}}, dnis | ForEach-Object {$.dnis = ($.dnis -join "|"); $} | Export-Csv -path ./CallRoutesFixed.csv -NoTypeInformation

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.