Forum Discussion
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
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" -NoTypeInformationPlease 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
3 Replies
- LeonPavesicSilver Contributor
Hi JFM_12,
to export the `ApplicationInstances` property as a string, you can use the following PowerShell script to manipulate the data before they are exported to CSV:
# 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 $customObject = [PSCustomObject]@{ Identity = $attendant.Identity 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
This script will get the `ApplicationInstances` property for each auto-attendant, convert it to a comma-separated string, and export the data to a CSV file named "AutoAttendants.csv." The `ApplicationInstances` property will be stored as a string in the CSV file.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
- JFM_12Iron Contributor
Hi
Great news.
What if I want to include also the
Identity,DefaultCallFlow,CallFlows etc.
Regards
Juan- LeonPavesicSilver Contributor
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" -NoTypeInformationPlease 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