Select SamAccountName - powershell script

Kelly Garcia
Kelly Garcia used Ask the Experts™
on
Hi All,

I have written the code below and it will not display the SamAccountName, please help!

get-mailbox -ResultSize Unlimited | Get-MailboxStatistics | where {$_.TotalItemSize -ge "4GB"} | Select-Object @{Name="DisplayName1";Expression={Get-Mailbox $_ | select -ExpandProperty SamAccountName}}, TotalItemSize, ItemCount, Database, TotalDeletedItemSize,DeletedItemCount, LastLoggedOnUserAccount, LastLogonTime, LastLogoffTime

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Senior Systems Administrator
Commented:
This seems to work, if there is a better way please let me know:

foreach ($m in get-mailbox -ResultSize Unlimited )

{Get-MailboxStatistics $m | where {$_.TotalItemSize -ge "4GB"} | Select-Object @{Name="DisplayName";Expression={Get-Mailbox $m | select -ExpandProperty SamAccountName}}, TotalItemSize, ItemCount, Database, TotalDeletedItemSize,DeletedItemCount, LastLoggedOnUserAccount, LastLogonTime, LastLogoffTime}

Open in new window

Kelly GarciaSenior Systems Administrator

Author

Commented:
this works

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial