SOLVED

RIF

Brass Contributor

Hi experts i have users list in csv file and i want to export these users Recoverable items folder above 50GB into csv file., please help me with the syntax. if i use the below syntax i can get for all users, but i want to pull report for selected users which are in the csv file.

 

Get-Mailbox -ResultSize Unlimited | Foreach{Get-MailboxFolderStatistics $_.name -FolderScope RecoverableItems |
Where{$_.FolderAndSubFolderSize -gt 50GB -and $_.Identity -like "*Recoverable Items*"}| 
Select Identity,folderandsubfoldersize} | export-csv "c:\50GB.csv" -NoTypeInformation -Append

1 Reply
best response confirmed by Rising Flight (Brass Contributor)
Solution

Hey @Rising Flight good to hear from you again.

 

To pull users this info from users with a CSV rather than all you just need to modify your first part into a loop. You can leave your syntax how you have it after the initial call if you need to test for the 50gb limit, but if your CSV already does that you may not have too.

 

Something like the following, where filedata.csv is your file. I am assuming filedata.csv has several fields ill need like MailboxName, etc.

 

$file = import-csv C:\filepath\filedata.csv

 

Foreach ($item in $file){
Get-Mailbox $item.Mailbox | Get-MailboxFolderStatistics $_.name -FolderScope RecoverableItems |
Where{$_.FolderAndSubFolderSize -gt 50GB -and $_.Identity -like "*Recoverable Items*"}| 
Select Identity,folderandsubfoldersize} | export-csv "c:\50GB.csv" -NoTypeInformation -Append

}

 

By putting the call for the get mailbox inside a loop, that has the mailbox name, you can grab that one at a time (assuming the CSV has just a list of the users you want), then loop through the command you have that already works.

 

Hope this helps!
Adam

1 best response

Accepted Solutions
best response confirmed by Rising Flight (Brass Contributor)
Solution

Hey @Rising Flight good to hear from you again.

 

To pull users this info from users with a CSV rather than all you just need to modify your first part into a loop. You can leave your syntax how you have it after the initial call if you need to test for the 50gb limit, but if your CSV already does that you may not have too.

 

Something like the following, where filedata.csv is your file. I am assuming filedata.csv has several fields ill need like MailboxName, etc.

 

$file = import-csv C:\filepath\filedata.csv

 

Foreach ($item in $file){
Get-Mailbox $item.Mailbox | Get-MailboxFolderStatistics $_.name -FolderScope RecoverableItems |
Where{$_.FolderAndSubFolderSize -gt 50GB -and $_.Identity -like "*Recoverable Items*"}| 
Select Identity,folderandsubfoldersize} | export-csv "c:\50GB.csv" -NoTypeInformation -Append

}

 

By putting the call for the get mailbox inside a loop, that has the mailbox name, you can grab that one at a time (assuming the CSV has just a list of the users you want), then loop through the command you have that already works.

 

Hope this helps!
Adam

View solution in original post