Exchange or Office 365 Mailbox Dumpster Report

By Ace Fekay
Published 2/21/2018

Intro

This is another quick script to enumerate what’s in the dumpster, that I’ve created to help my day to day tasks. I hope you find it helpful.

Scope

This script enumerates an Exchange or Office 365 Dumpster, Purges, and Versions folders.

Note:

  • Dumpster and Deletions Report provides Size Values for the mailbox
  • Deleted items’, ‘Recover Deleted Items’ (Dumpster), and ‘Purges’ values.
    Does not apply to Mailusers” -ForegroundColor cyan
    *** If Lit Hold is present, Recover and Purges will be larger and must be ignored.) ***

The ‘Recoverable Items’ folder contains the following subfolders

  1. Recoverable Items: This is the total amount combined in Deletions, Calendar Logging, Purges, and Versions.
  2. Calendar Logging:  For Calendar diagnostic purposes

  3. Deletions
    : Recover Deleted Items or the ‘Dumpster'”
         This subfolder contains all items deleted from the Deleted Items folder.
  4. Versions:          If In-Place Hold or Litigation Hold is enabled:
    This subfolder contains the original and modified copies of the deleted items.”
  5. Purges:            If either Litigation Hold or single item recovery is enabled:”
    This subfolder contains all items that are hard deleted.

Script

I did not make this into a function, although it can easily be converted. To run it, for the $RecipientName variable, just enter the username, email address, displayName, or their sAMAccountName, and fire away.

“======================================================”
$RecipientName = “user’s email address, DisplayName, or sAMAccountName”
$RecipientDisplayName = (get-recipient $RecipientName).displayname

Optional (for reporting purposed):

$RecipientNetBIOSName = (get-recipient $RecipientName).name
$RecipientPrimAlias = (get-recipient $RecipientName).PrimarySmtpAddress

“======================================================” -ForegroundColor Cyan                   
  write-host “Dumpster and Deletions Report for ‘$RecipientDisplayName’ ($RecipientName) (Does not apply to Mailusers or Contacts):” “$(get-date)” -ForegroundColor Yellow
     Write-host “======================================================”
Write-host “Dumpster and Deletions Report provides Size Values for the mailbox ‘Deleted items’, ‘Recover Deleted Items’ (Dumpster), and ‘Purges’ values.”  -ForegroundColor Cyan
     Write-Host “Does not apply to Mailusers” -ForegroundColor cyan
     Write-Host “*** If Lit Hold is present, Recover and Purges will be larger and must be ignored.) ***”  -ForegroundColor Red
     Write-Host “***”
     Write-host “The ‘Recoverable Items’ folder contains the following subfolders:” -ForegroundColor Yellow
     Write-Host ”   Recoverable Items: This is the total amount combined in Deletions, Calendar Logging, Purges, and Versions.”
     Write-Host ”   Calendar Logging:  For Calendar diagnostic purposes”
     Write-Host ”   Deletions:         Recover Deleted Items or the ‘Dumpster'”
     Write-host ”                      This subfolder contains all items deleted from the Deleted Items folder. “
     Write-Host ”   Versions:          If In-Place Hold or Litigation Hold is enabled:”
     Write-Host ”                      This subfolder contains the original and modified copies of the deleted items.”
     Write-Host ”   Purges:            If either Litigation Hold or single item recovery is enabled:”
     Write-host ”                      This subfolder contains all items that are hard deleted.”
     Write-host “======================================================” -ForegroundColor Cyan
Get-MailboxFolderStatistics $RecipientName -FolderScope RecoverableItems | ft Name,FolderAndSubfolderSize, @{name=”LitigationHoldEnabled”;expression={(Get-mailbox $RecipientName).LitigationHoldEnabled}} –a
##########################################################

Report Output

(Watch the word-wrap):

=================================================================================================
Dumpster and Deletions Report for ‘User DisplayName’ (SAP Legal Operations) (Does not apply to Mailusers): 03/27/2018 11:22:01
=================================================================================================
Dumpster and Deletions Report provides Size Values for the mailbox ‘Deleted items’, ‘Recover Deleted Items’ (Dumpster), and ‘Purges’ values.
Does not apply to Mailusers
*** If Lit Hold is present, Recover and Purges will be larger and must be ignored.) ***
***
The ‘Recoverable Items’ folder contains the following subfolders:
    Recoverable Items: This is the total amount combined in Deletions, Calendar Logging, Purges, and Versions.
    Calendar Logging:  For Calendar diagnostic purposes
    Deletions:         Recover Deleted Items or the ‘Dumpster’
                       This subfolder contains all items deleted from the Deleted Items folder.
    Versions:          If In-Place Hold or Litigation Hold is enabled:
                       This subfolder contains the original and modified copies of the deleted items.
    Purges:            If either Litigation Hold or single item recovery is enabled:
                       This subfolder contains all items that are hard deleted.
=================================================================================================

Name              FolderAndSubfolderSize     LitigationHoldEnabled
—-              ———————-     ———————
Recoverable Items 1.32 MB (1,383,783 bytes)                  False
Calendar Logging  0 B (0 bytes)                              False
Deletions         1.196 MB (1,253,945 bytes)                 False
Purges            126.8 KB (129,838 bytes)                   False
Versions          0 B (0 bytes)                              False

Clear on the picture for a full view:

image

Summary

I hope this helps!

Published 3/27/2018

Ace Fekay
MVP, MCT, MCSE 2012, MCITP EA & MCTS Windows 2012|R2, 2008|R2, Exchange 2013|2010EA|2007, MCSE & MCSA 2003/2000, MCSA Messaging 2003
Microsoft Certified Trainer
Microsoft MVP – Mobility

As many know, I work with Active Directory, Exchange server, and Office 365 engineer/architect, and an MVP in Active Directory and Identity Management, and I’m an MCT as well. I try to strive to perform my job with the best of my ability and efficiency, even when presented with a challenge, and then help others with my findings in case a similar issue arises to help ease their jobs. Share the knowledge, is what I’ve always learned.

I’ve found there are many qualified and very informative websites that provide how-to blogs, and I’m glad they exists and give due credit to the pros that put them together. In some cases when I must research an issue, I just needed something or specific that I couldn’t find or had to piece together from more than one site, such as a simple one-liner or a simple multiline script to perform day to day stuff.

I hope you’ve found this blog post helpful, along with my future scripts blog posts, especially with AD, Exchange, and Office 365.

clip_image0023 clip_image0043 clip_image0063 clip_image0083 clip_image0103 clip_image0123 clip_image0143 clip_image0163

Complete List of Technical Blogs
https://blogs.msmvps.com/acefekay/

This posting is provided AS-IS with no warranties or guarantees and confers no rights.


 

Get-QADGroupMember to CSV

Prologue

Ace Fekay here again.

You might say to yourself this is some really simple stuff. Sure, it might be, for the pro. As many of you know, I’m an avid Active Directory and Exchange server engineer/architect, and an MVP in Active Directory.

Therefore with AD, Exchange, and Office 365, you will find that scripting comes into play more and more with your daily tasks.  The main reason I’m posting simple scripts is that to get the job done, I just needed an arsenal of simple quickie scripts when called upon a simple task, such as this one, when tasked to quickly get a list of users in a group.

I hope this, and my future scripts, especially with Office 365, help you out.

Scope

I needed to get a user membership list from a global group called, “Marketing Dept,” into a CSV. Group scope doesn’t matter. I just need a list of the members because the share owner that the group is controlling access, needed a list to ensure that it’s current and to clean up any disabled accounts from users that have left the company.

And yes, this is simple stuff. The main reason I’m posting this, and I will be posting much more, including Office 365 scripts, is that I had to look it up and there is no one place to get all of this at the simple level. All I see are elaborate scripts that do more than what I needed. Hence, my posts.

 

I usually kick it off with a get-credential because I run this from my workstation logged on with my non-admin account. And because I work in a multi-forest, multi domain environment, I must connect to the specific domain where the group exists.

Of course, we must add the PS Quest snap-in. In addition, I use the “-NoTypeInformation” switch to suppress the silly “Type” data that shows up in the output.

Code

get-credential
add-pssnapin Quest*
connect-qadservice domain2
Get-QADGroupMember “Marketing Dept” | Select-Object DisplayName,Name,AccountIsDisabled | Export-Csv c:\output\Domain2-MarketinDept.csv –NoTypeInformation

Comments are welcomed.

==================================================================

Summary

I hope this helps!

Published 8/17/2015

Ace Fekay
MVP, MCT, MCSE 2012, MCITP EA & MCTS Windows 2008/R2, Exchange 2013, 2010 EA & 2007, MCSE & MCSA 2003/2000, MCSA Messaging 2003
Microsoft Certified Trainer
Microsoft MVP – Directory Services

clip_image00262 clip_image00462 clip_image00662 clip_image00862 clip_image01062 clip_image01262 clip_image01462

Complete List of Technical Blogs: http://www.delawarecountycomputerconsulting.com/technicalblogs.php

This posting is provided AS-IS with no warranties or guarantees and confers no rights.

PowerShell: Getting AD groups of one User and Add them to a List of Other Users

Prologue

Ace here again. Yep, me again. I’ve been on the sidelines lately with a big mail migration, then changed roles to the AD and Windows management side of things.

Part of what I do is perform necessary file maintenance (FSRM, DFS, fileserver migration, etc.), and of course, respond to tickets for requests or issues.

One request that came in was for 16 new users that are to have identical group memberships as a current user. I looked at the group membership of the user in question and saw he was part of 11 or 12 groups. Hmm, and he wants this done for 16 users? I could sit there and add group to each user one at a time. Nah, too much work.

So I thought to try to do it programmatically, because who knows when this will come up again.

Script

It’s pretty straight forward.

#===========================================================================================
# This was created for a ticket request to mimic one user, SomeSamAccountUsername, group membership to add to a list of user accounts.
# By Ace Fekay 7/15/2015
#
# First, get a memberOf for SomeSamAccountUsername and save it to a file called c:\PSScripts\SomeSamAccountUsername-grouplist.txt
#     Run Get-QADMemberOf SomeSamAccountUsername
#
#     Copy and paste the output from the screen to the file
#     In the file, keep the DN values and delete everything else.
#
# Second, get a list of the user accounts that you want adjusted from the ticket owner
#     Then save the list in another text file called c:\PSscripts\Usernames.txt
#     Prefix the user accounts with the domain name, such as philly\username
#
# Third, read the first user in the list, then add the groups to that user, then read the next user in the list, repeat.
#===========================================================================================

# The next line adds all of the Quest tools.

Add-PSSnapIn Quest *
Get-QADMemberOf SomeSamAccountUsername

#===========================================================================================
# Sample output from Get-QADMemberOf SomeSamAccountUsername:
#===========================================================================================
#
#Name                           Type            DN                                                                                                            
##
#Domain Users                   group           CN=Domain Users,OU=IT,DC=philly,DC=contoso,DC=com                                                       
#Deployment Technician          group           CN=Deployment Technician,OU=IT,DC=philly,DC=contoso,DC=com                                         
#Desktop-Technician             group           CN=Desktop-Technician,OU=IT,DC=philly,DC=contoso,DC=com                                                     
#AddComputerToDomain            group           CN=AddComputerToDomain,OU=IT,DC=philly,DC=contoso,DC=com                                               
#Vendor-A-contractors           group           CN=Vendor-A-contractors,OU=IT,DC=philly,DC=contoso,DC=com                                               
#General-Group                  group           CN=General-Group,OU=IT,DC=philly,DC=contoso,DC=com                                                            
#Wireless-Users                 group           CN=Wireless-Users,OU=IT,DC=philly,DC=contoso,DC=com                                                
#Group-B                        group           CN=Group-B,OU=IT,DC=philly,DC=contoso,DC=com                                                                
#IT-Staff                       group           CN=IT-Staff,OU=IT,DC=philly,DC=contoso,DC=com                                                      
#IT-Admins                      group           CN=IT-Admins,OU=IT,DC=philly,DC=contoso,DC=com                                                     
#IT-Technicians                 group           CN=IT-Technicianss,OU=IT,DC=philly,DC=contoso,DC=com                                                   
#Client-Support                 group           CN=Client-Support,OU=IT,DC=philly,DC=contoso,DC=com   

# #=================================================================================================
# Sample of what C:\PSScripts\groupmembership\SomeSamAccountUsername-grouplist.txt  will look like:
# #=================================================================================================
# CN=Domain Users,OU=IT,DC=philly,DC=contoso,DC=com                                                       
# CN=Deployment Technician,OU=IT,DC=philly,DC=contoso,DC=com                                         
# CN=Desktop-Technician,OU=IT,DC=philly,DC=contoso,DC=com                                                     
# CN=AddComputerToDomain,OU=IT,DC=philly,DC=contoso,DC=com                                               
# CN=Vendor-A-contractors,OU=IT,DC=philly,DC=contoso,DC=com                                               
# CN=General-Group,OU=IT,DC=philly,DC=contoso,DC=com                                                            
# CN=Wireless-Users,OU=IT,DC=philly,DC=contoso,DC=com                                                
# CN=Group-B,OU=IT,DC=philly,DC=contoso,DC=com                                                                
# CN=IT-Staff,OU=IT,DC=philly,DC=contoso,DC=com                                                      
# CN=IT-Admins,OU=IT,DC=philly,DC=contoso,DC=com                                                     
# CN=IT-Technicians,OU=IT,DC=philly,DC=contoso,DC=com                                                   
# CN=Client-Support,OU=IT,DC=philly,DC=contoso,DC=com  
#=================================================================================================

#===========================================================================================
# Sample of what C:\PSScripts\groupmembership\List-Of-Usernames.txt username list will look like:
#==========================================================================================
# philly\username1
# philly\username2
# philly\username3
# philly\username4
# philly\username5
# philly\username6
# philly\username7
# philly\username8
# philly\username9
# philly\username10
# philly\username11
# philly\username12
# philly\username13
# philly\username14
# philly\username15
# philly\username16
#==========================================================================================

$GroupList = get-content C:\PSScripts\groupmembership\SomeSamAccountUsername-grouplist.txt 
$UsernameList = get-content C:\PSScripts\groupmembership\List-Of-Usernames.txt

# Now pull in each user one a time:
Foreach ($Username in $UsernameList)
{
 
# Now pull in each group one at a time and add them to the user
   Foreach ($Group in $GroupList)
  
# Add the group to the user 
    {
    Add-QADGroupMember  -Identity $Group -Member $Username
   
# Write out on the screen what username is and what group they were added to:
    write-host $Username “has been added to ” $Group
   
# Repeat for next group until all groups are done.
   }
  
# Repeat for the next user
}
#===========================================================================================
# That’s it!
#===========================================================================================

 

 

Summary

I hope this helps!

Published 7/27/2015

Ace Fekay
MVP, MCT, MCSE 2012, MCITP EA & MCTS Windows 2008/R2, Exchange 2013, 2010 EA & 2007, MCSE & MCSA 2003/2000, MCSA Messaging 2003
Microsoft Certified Trainer
Microsoft MVP – Directory Services

clip_image00262 clip_image00462 clip_image00662 clip_image00862 clip_image01062 clip_image01262 clip_image01462

Complete List of Technical Blogs: http://www.delawarecountycomputerconsulting.com/technicalblogs.php

This posting is provided AS-IS with no warranties or guarantees and confers no rights.