Hi!
I write PowerShell advanced function to to query Active Directory using Exchange 2010 management shell (PowerShell 2.0).
In my function I query recipients and next for any recipient I take email addresses (proxy addresses). As a results as a result I would like create custom objects collection.
For create any item for collection I use construction like this
$Result = New-Object PSObject
$Result | Add-Member -Type 'NoteProperty' -Name RecipientIdentifier -Value $CurrentRecipientIdentifier
$Result | Add-Member -type 'NoteProperty' -name RecipientAlias -value $CurrentRecipient.Alias
next I enumerate addresses by prefixes (using loops) and create next properties for $Result variable e.g.
[String]$CurrentPrefixAddressCountColumnName = "{0}{1}{2}" -f "AddressesForPrefix_", $CurrentPrefix, "_Count"
$Result | Add-Member -Type 'NoteProperty' -Name $CurrentPrefixAddressCountColumnName -Value $EmailsWithPrefixCountat the end I add my $Result to $Results variable (which is intialized as $Results = @() ) using $Results += Result .
And the issue is that $Results has only properties which were added by the first $Result subobject
The full function is published at GitHub .
Thank you in advance for any help.
Wojciech Sciesinski