I am creating a custom object that may be redundant, but this is the easiest way I've found.
Here is a sample code to play. Let me know if it caused any problems or additional questions:
$outputCollection = @() $users = Get-User -Filter "..." $mailboxes = Get-Mailbox -Filter "..." $users | Foreach-Object { #Associate objects $userObject = $_ $mailboxObject = $mailboxes | Where-Object {$_.Name -eq $userObject.Name}
Another option that should work is called computed properties:
Get-User -Filter "..." | Select Name, UserAttribute, @{Name="OtherAttribute"; Expression={(Get-Mailbox $_.Name).MailboxAttribute}}
... note that this will result in a new Get-Mailbox command for each entry, which potentially increases the execution time
Chris n
source share