I made the script below when a student sent a mass email to everyone in the school . I tried using piping to make this a possible one-liner but there was whitespace added and the damn trim function wouldn't work.
I couldn't find anything on the web that did this so I hope this will be useful for anyone else.
add-pssnapin Microsoft.Exchange.Management.PowerShell.E2010
import-module ActiveDirectory
$filepath = "C:\students.csv"
Get-ADGroupMember "Students" | Export-CSV $filepath
Import-CSV $filepath -Header dish,name,oc,uid,samaccname,sid | Foreach-Object{
Set-Mailbox -Identity $_.samaccname -RecipientLimits 2
}