Forum Discussion
RIF
- Sep 14, 2018
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
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