Script for mailbox size and last logon date for exchange online to Excel

Welcome Forums General PowerShell Q&A Script for mailbox size and last logon date for exchange online to Excel

Viewing 1 reply thread
  • Author
    Posts
    • #218616
      Participant
      Topics: 1
      Replies: 0
      Points: 12
      Rank: Member
      connect-exchangeonline
      
      $Excel = New-Object -ComObject Excel.Application
      $Excel.Visible = $True
      $Excel = $Excel.Workbooks.Add()
      $Sheet = $Excel.Worksheets.Item(1)
      $Sheet.Name = “Mailbox Stats”
      
      $Sheet.Cells.Item(1,1) = “Name”
      $Sheet.Cells.Item(1,2) = “Last Log On”
      $Sheet.Cells.Item(1,3) = “MailBox Size”
      
      $intRow = 2
      
      $box = get-exomailbox | select userprincipalname
      
      foreach ($i in $box.userprincipalname){
      
      $stats = Get-EXOMailboxStatistics -Identity $i -Properties lastlogontime | select displayname, lastlogontime, @{label=”TotalItemSize”;expression={[math]::Round(`
      ($_.TotalItemSize.ToString().Split("(")[1].Split(" ")[0].Replace(",","")/1MB),2)}}
      
      $Sheet.Cells.Item($intRow, 1) = $stats.displayname
      $Sheet.Cells.Item($intRow, 2) = $stats.lastlogontime
      $Sheet.Cells.Item($intRow, 3) = $stats.TotalItemSize
      $intRow ++
      
      }
      
      • This topic was modified 1 month, 2 weeks ago by barrond1723. Reason: Add Tag
      • This topic was modified 1 month, 2 weeks ago by barrond1723.
    • #218622
      Participant
      Topics: 4
      Replies: 2247
      Points: 5,484
      Helping Hand
      Rank: Community MVP

      Dennis, welcome to Powershell.org. Please take a moment and read the very first post on top of the list of this forum: Read Me Before Posting! You’ll be Glad You Did!.

      When you post code or error messages or sample data or console output format it as code using the code tags “PRE“, please. You can edit your existing post. You don’t have to create a new one. Thanks in advance.

      And BTW: – you should ask a clear question.

Viewing 1 reply thread
  • You must be logged in to reply to this topic.