Forum Discussion

JFM_12's avatar
JFM_12
Iron Contributor
Sep 15, 2023
Solved

Get-CsAutoAttendant export ApplicationInstances as String and not as SystemObject

Hello When I do a Get-CsAutoAttendant the ApplicationInstances are exported in a CSV as "System.String[]" How can I change it. Regards JFM_12
  • LeonPavesic's avatar
    LeonPavesic
    Sep 15, 2023

    Hi JFM_12,

    If you want to include additional properties like `Identity`, `DefaultCallFlow`, and `CallFlows` in the CSV export along with the modified `ApplicationInstances` property, you can try update the script as follows (I haven't tested it yet):

     

    # Run Get-CsAutoAttendant and store the results in a variable
    $autoAttendants = Get-CsAutoAttendant
    
    # Create an empty array to store the modified data
    $exportData = @()
    
    # Loop through each auto-attendant
    foreach ($attendant in $autoAttendants) {
    # Convert the ApplicationInstances property to a comma-separated string
    $applicationInstances = $attendant.ApplicationInstances -join ', '
    
    # Create a custom object with the modified data, including Identity, DefaultCallFlow, and CallFlows
    $customObject = [PSCustomObject]@{
    Identity = $attendant.Identity
    DefaultCallFlow = $attendant.DefaultCallFlow
    CallFlows = $attendant.CallFlows -join ', '
    ApplicationInstances = $applicationInstances
    }
    
    # Add the custom object to the export data array
    $exportData += $customObject
    }
    
    # Export the modified data to a CSV file
    $exportData | Export-Csv -Path "AutoAttendants.csv" -NoTypeInformation

     

    Please click Mark as Best Response & Like if my post helped you to solve your issue.
    This will help others to find the correct solution easily. It also closes the item.


    If the post was useful in other ways, please consider giving it Like.


    Kindest regards,


    Leon Pavesic