Forum Discussion
StefanoC66
Oct 10, 2024Iron Contributor
Multiple @name substitution in one line import
I'm trying to export all the "conditional" attributes from the Get-DynamicDistributionGroup into a csv file
ConditionalCompany : {}
ConditionalStateOrProvince : {}
ConditionalCustomAttribute1 : {}
ConditionalCustomAttribute2 : {}
these attributes are a Microsoft.Exchange.Data.MultiValuedProperty`1[System.String] so to correctly export them to csv we should use the following for each of them
@{Name="ConditionalCustomAttribute1";Expression={($_.ConditionalCustomAttribute1)}}
@{Name="ConditionalCustomAttribute2";Expression={($_.ConditionalCustomAttribute2)}}
...
I was wondering if there's a way to "expand" the * inside the @{} instead
something like
@{Name="ConditionalAttribute*";Expression={($_.ConditionalAttribute*)}}
- sdtslmnBrass Contributor
$attributes = @("ConditionalCompany", "ConditionalStateOrProvince", "ConditionalCustomAttribute1", "ConditionalCustomAttribute2") $dynamicGroup = Get-DynamicDistributionGroup $properties = $attributes | ForEach-Object { @{Name=$_; Expression={ $_.($_) }} } $dynamicGroup | Select-Object -Property Name, $properties | Export-Csv -Path "output.csv" -NoTypeInformation