Monday, July 22, 2013

So this might be why we compile code

So while goofing around and being a bit of a romantic I put Powershell into an infinite loop with a cheesy bit of text.

What was interesting to me (apart from the surprising amount of kudos from the missus) was the CPU load this created. One whole core running at full just to write a string and add 1 to a number.

I guess this is why we compile 'proper' code. Interpreted code is REALLY slow.

Tuesday, July 9, 2013

Deleting emails from Users Mailboxes

We've all had a moment when a white faced user comes up to us and asks THAT question about recalling emails.

"I've just hit send on a super secret document and CC'd the whole organisation..." they stammer "Is there any way to recall it?"

Well if they've sent it out to the world they're gunna have a bad time... If it's just within their orgnaisation their exchange admins can save the day! 3 lines of powershell and it'll be like it never happened.

you need full access rights to the recipients mailbox, your exchange administrator can run this command;
Get-ADGroupMember "THEDISTROLISTTHATGOTTHEEMAIL" | Add-MailboxPermission -identity {$} -User YOU -AccessRights FullAccess -InheritanceType All 

You need 2 things from the user the subject of their email and the time frame it was sent;
Get-ADGroupMember "THEDISTROLISTTHATGOTTHEEMAIL" | Export-Mailbox -Identity {$} -subject "SUBJECTOFUSERSSHAMEMAIL" –DeleteContent -StartDate "08/07/2013" -EndDate "09/07/2013"

Now just cleanup after yourself
Get-ADGroupMember "THEDISTROLISTTHATGOTTHEEMAIL" | Remove-MailboxPermission -Identity {$} -user YOU-AccessRights fullaccess

That's it. Run that and marvel in the power of the shell!

If you've never seen this work before you may be a little trepidatious. So why not try it out on your own mailbox before you pipe a while group through? Just use the includefolders argument and point it at a /test folder;

Export-Mailbox -Identity YOU -includefolders "/TEST" -subject "SUBJECTOFUSERSSHAMEMAIL" –DeleteContent -StartDate "08/07/2013" -EndDate "09/07/2013"