ndalmolin_13
asked on
Help with formatting a table in Powershell
Hello PowerShell Experts
I need a little help with formatting a table. I have the following command that queries Exchange for mailboxes that received an email from a specific address.
$Mailboxes = get-messagetrackinglog –server ExchangeServer –sender nick@domain.com | `
where-object {$_.eventid –eq “deliver” }| select –expandproperty recipients
This produces the following list:
sales@xyz.com
accounting@xyz.com
finance@xyz.com
Now I want to find out who has access to these mailboxes, so I do the following:
$Mailboxes = get-messagetrackinglog –server ExchangeServer –sender nick@domain.com | `
where-object {$_.eventid –eq “deliver”} | select –expandproperty recipients
Foreach ($mailbox in $mailboxes) {
Get-mailboxpermission $mailbox | select User
}
This gives me a list of users for each mailbox.
I would like to create a table with this information. The table would look like:
Mailbox User
sales@xyz.com xyz\mary
sales@xyz.com xyz\bob
sales@xyz.com xyz\joe
accounting@xyz.com xyz\sally
accounting@xyz.com xyz\fred
finance@xyz.com xyz\joe
finance@xyz.com xyz\sally
finance@xyz.com xyz\fred
finance@xyz.com xyz\Eugene
My thoughts were something like this, but this isn’t working:
$Mailboxes = get-messagetrackinglog –server ExchangeServer –sender nick@domain.com | `
where-object {$_.eventid –eq “deliver”} | select –expandproperty recipients
Foreach ($mailbox in $mailboxes) {
Get-mailboxpermission $mailbox | select `
@{n=”Mailbox”;e=”$mailbox” }
@{n=”Users”;e={$_.User}}
}
Any help with this would be greatly appreciated.
Thanks,
Nick
I need a little help with formatting a table. I have the following command that queries Exchange for mailboxes that received an email from a specific address.
$Mailboxes = get-messagetrackinglog –server ExchangeServer –sender nick@domain.com | `
where-object {$_.eventid –eq “deliver” }| select –expandproperty recipients
This produces the following list:
sales@xyz.com
accounting@xyz.com
finance@xyz.com
Now I want to find out who has access to these mailboxes, so I do the following:
$Mailboxes = get-messagetrackinglog –server ExchangeServer –sender nick@domain.com | `
where-object {$_.eventid –eq “deliver”} | select –expandproperty recipients
Foreach ($mailbox in $mailboxes) {
Get-mailboxpermission $mailbox | select User
}
This gives me a list of users for each mailbox.
I would like to create a table with this information. The table would look like:
Mailbox User
sales@xyz.com xyz\mary
sales@xyz.com xyz\bob
sales@xyz.com xyz\joe
accounting@xyz.com xyz\sally
accounting@xyz.com xyz\fred
finance@xyz.com xyz\joe
finance@xyz.com xyz\sally
finance@xyz.com xyz\fred
finance@xyz.com xyz\Eugene
My thoughts were something like this, but this isn’t working:
$Mailboxes = get-messagetrackinglog –server ExchangeServer –sender nick@domain.com | `
where-object {$_.eventid –eq “deliver”} | select –expandproperty recipients
Foreach ($mailbox in $mailboxes) {
Get-mailboxpermission $mailbox | select `
@{n=”Mailbox”;e=”$mailbox”
@{n=”Users”;e={$_.User}}
}
Any help with this would be greatly appreciated.
Thanks,
Nick
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Awesome!! Thanks.
Open in new window