Scenario: You want to pull in values/output from other commands into the output of a different command. In Exchange we know not all uniquely identifiable properties are attached to each exchange command:
Example: The Alias can be found in get-mailbox, but is not tied to the output of a get-mailboxstatistics command.
In the scriptlet below, we are going to tie together the following properties in a single one-liner using expressions within the Select-Object statement:
- Displayname from get-mailboxstastics
- TotalItemSize & TotalDeletedItemSize from get-mailboxstatistics
- HasActivesyncDevicePartnership from get-casmailbox
- Alias from get-mailbox
- MobileDevice Count from get-mobiledevice
Scriptlet:
Get-mailboxstatistics steve | Select Displayname,`
Total*Size,`
@{Name=”User_Email”;Expression={$u = $_.LegacyDN; (@(get-mailbox “$u”)).primarysmtpaddress}},`
@{Name=”Alias”;Expression={$u = $_.LegacyDN; (@(get-mailbox “$u”)).alias}}, `
@{Name=”HasActiveSyncDevicePartnership”;Expression={$u = $_.LegacyDN; (@(get-casmailbox “$u”)).HasActiveSyncDevicePartnership}}, `
@{Name=”MobileDeviceCount”;Expression={$u = $_.LegacyDN; (@(get-mobiledevice -mailbox “$u”)).count}}
Another example: Pulling the Get-mailboxfolderpermission for the calendar, but including the primarysmtpaddress in the Select statement of the delegated user:
get-mailboxfolderpermission steve:calendar | Select FolderName,`
User,`
@{Name=”User_Email”;Expression={$u = $_.user; (@(get-mailbox “$u”)).primarysmtpaddress}},`
AccessRights