What does this code do?

A quick bit of code that will display a total number of items in a site collections recycle bin. 
This will display how many are in each stage and then a total.


Example:

First Stage:10

Second Stage: 20

Total: 30

You can then use this metric to do what ever you want. You could also modify this to loop through a whole web applications or across the whole farm

 

 

PowerShell
Edit|Remove
$site = (Get-SPSite “site”).RecycleBin 
 
$first = ($site | ?{$_.ItemState -eq "FirstStageRecycleBin"}).count 
$second = ($site | ?{$_.ItemState -eq "SecondStageRecycleBin"}).count 
 
$total = [int]$first+[int]$second 
 
Write-Host "First Stage:" $first 
Write-Host "Second Stage:" $second 
Write-Host "Total:" $total -ForegroundColor Green