Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Need some help in modifying Powershell script to display mailbox size ?

$
0
0

Hi All,

Can anyone here please assist me in how to add one more which can display the size of the mailbox size in MB?

Here's the script that I was able to execute it successfully to display all mailboxes with the last sent items older than 90 days (customizable):

 

$xDays = 90 

Get-Mailbox -ResultSize Unlimited -RecipientTypeDetails UserMailbox | Foreach-Object {

         $si = Get-MailboxFolderStatistics $_ -IncludeOldestAndNewestItems -FolderScope SentItems 

         if($si.NewestItemReceivedDate -AND (New-TimeSpan $si.NewestItemReceivedDate.ToLocalTime()).Days -ge $xDays) { 

            #$_ 

               New-Object PSObject -Property @{

                     Name = $_.Name

                     Alias = $_.Alias

                         PrimarySmtpAddress = $_.PrimarySmtpAddress

                         WhenCreated = $_.WhenCreated

                         Database = $_.Database

                      LastSentItemDate = $si.NewestItemReceivedDate 

                         LastLogonTime = $si.LastLogonTime

               } 

      } 

} | Select Name, Alias, PrimarySmtpAddress, LastSentItemDate, WhenCreated, LastLogonTime, Database | Sort LastSentItemDate | Export-Csv -Path C:\temp\Inactive90Days.csv -NoTypeInformation -UseCulture

 

I tried to add some attributes here on Bold but still not giving me any result:

$xDays = 90 

Get-Mailbox -ResultSize Unlimited -RecipientTypeDetails UserMailbox | Foreach-Object {

         $MailboxStats = Get-MailboxStatistics $_  

         $si = Get-MailboxFolderStatistics $_ -IncludeOldestAndNewestItems -FolderScope SentItems 

         if($si.NewestItemReceivedDate -AND (New-TimeSpan $si.NewestItemReceivedDate.ToLocalTime()).Days -ge $xDays) { 

            #$_ 

               New-Object PSObject -Property @{

                     Name = $_.Name

                     Alias = $_.Alias

                         PrimarySmtpAddress = $_.PrimarySmtpAddress

                         WhenCreated = $_.WhenCreated

                         Database = $_.Database

                      LastSentItemDate = $si.NewestItemReceivedDate 

                         LastLogonTime = $si.LastLogonTime

                         MailboxSize = $MailboxStats.totalitemsize.value.ToMB()

               } 

      } 

} | Select Name, Alias, PrimarySmtpAddress, LastSentItemDate, WhenCreated, LastLogonTime, Database, MailboxSize | Sort LastSentItemDate | Export-Csv -Path C:\temp\Inactive90Days.csv -NoTypeInformation -UseCulture

 

This is the error that I got:

Pipeline not executed because a pipeline is already executing. Pipelines cannot be executed concurrently.
    + CategoryInfo          : OperationStopped: (Microsoft.Power...tHelperRunspace:ExecutionCmdletHelperRunspace) [],
   PSInvalidOperationException
    + FullyQualifiedErrorId : RemotePipelineExecutionFailed

So any help would be greatly appreciated.

Thanks in advance.


Viewing all articles
Browse latest Browse all 6937

Trending Articles