Script To Export Then Disconnect an Exchange Mailbox

Filed in Microsoft Exchange 2010, PowerShell

A situation came up where I needed to be able to remove a user’s mailbox, but his supervisor wanted a copy of the contents in the form of a pst file. It would be easy enough to export the mailbox then go back later to disable it manually, but where’s the fun in that? This script accomplishes the same thing in a much more hands-off way.

Here’s how:

  1. Accepts a command line option for the username, displayname, alias, etc.
  2. Exports the mailbox to a pre-set network location.
  3. Waits for the export to complete before disabling the mailbox. (This will monopolize the PowerShell window, so you might want to run it in a separate PS instance. You can do this from within another script using “Start-Process powershell.exe -argument ‘-command “ExportAndDisco.ps1 username”

This script is specifically for Exchange 2010, but should work on 2013 with the appropriate modifications.

# Defines the commandline parameter as $mbx.
param([string]$mbx)

# Defines the export path. This value MUST be a UNC path
# and MUST end with a back slash.
$ExportPath = "\\servername\server\"

# Loads Exchange 2010 PowerShell snapin if it's not already loaded.
if ((get-pssnapin -name Microsoft.Exchange.Management.PowerShell.E2010 `
	-EA silentlycontinue) -eq $null) {
	add-pssnapin Microsoft.Exchange.Management.PowerShell.E2010
}

# Checks for an existing export job.
if ((Get-MailboxExportRequest | ?{$_.FilePath -like "*$mbx.pst"}) {
    write-host "There is an existing export request" `
	-ForegroundColor Red
    write-host "for this mailbox. Remove that request " `
	-ForegroundColor Red
    write-host "and try again." `
	-ForegroundColor Red
    exit
}

# Exports the mailbox. 
New-MailboxExportRequest $mbx -FilePath `
	$ExportPath+$mbx+".pst" -BadItemLimit 50 `
	-confirm:$false

# Checks the export status every 60 seconds. Continues when the
# status = "Completed".
do {sleep 60}
while ((Get-MailboxExportRequest | `
	?{$_.FilePath -like "*$mbx.pst"}).Status -ne "Completed")
	
# Disables the mailbox.
Disable-Mailbox $mbx -Confirm:$false
 
Click to view/hide

NSFW Gear – The COFFEEBOXX

Filed in NSFW Gear

Instead of NSFW, I should say that this gadget is actually very SFW. In fact, it’s safe for just about any workplace you can think of except zero-gravity environments. It’s the COFFEEBOXX, a rugged, go-anywhere, use-anywhere, K-cup compatible coffee maker.

Ultra-SFW coffee maker

Unfortunately, it doesn’t exist yet. This is a Kickstarter project trying to raise money get the product onto the market. The Kickstarter page says…

The COFFEEBOXX™ is built Beyond Rugged™ to perform where other coffee makers fear to tread. It’s field tested to meet standards no one dared to set: crush-proof, dust-proof, spill-proof, rust-proof, water resistant, impact resistant. It uses the latest single-serve technology to deliver your favorite coffee anywhere you work and play.

This is a very cool product, and I’d like to have one. I would give them away for birthday presents and such. There are two changes I’d like to see that would make this a much more appealing and useful product:

  1. Lose the power cord. If I get the hankerin’ for some Joe in the deepest shaft of the salt mine, I might not have an electrical outlet handy. (Well, actually, in the salt mine, I probably would, but you know what I mean.) Give this thing a backup battery with the juice to fill at least a dozen cups.
  2. Add a two stage water filter, one stage for course filtering, plus a Berkey filter for getting out the stray molecular toxins that remain. Then I can just scoop some water off the mine floor without carrying it down with me.

But, you know… It occurs to me that there might already be COFFEEBOXX-killer on the market. It’s cheap, rugged, and doesn’t require a power source, whether external or internal. It’s called a Thermos. Maybe it won’t survive a tunnel collapse, but if the tunnel collapses, you’ll have more important things to worry about.

 
Click to view/hide

Exchange Users Unable to Connect with Outlook 2010

Filed in Outlook 2010Tags: ,

Over the past couple of weeks, I’ve had a rash of Exchange users who are unable to connect using Outlook. They don’t get an error message; Outlook just spins its wheels forever. If they try to set up a new Mail profile via the Control Panel app, it will connect to the server to verify the account, but then freeze trying to configure the local profile. The user can log in and send/receive email in OWA and on other computers, so it’s not an account-related issue.

These are the steps I tried to resolve the problem:

  • Delete the Mail profile and the cached Outlook data under %appdata%\Microsoft and %localappdata%\Microsoft. (Never worked.)
  • Repair the email account from within Outlook. (Never worked.)
  • Repair Microsoft Office. (Never worked.)
  • Completely uninstall, then reinstall Microsoft Office. (Worked about 50% of the time.)
  • Create a new local Windows profile for the user. (Worked 100% of the time I tried it.)

I haven’t been able to pin the source of the problem down to any particular change, whether something on our network or a Microsoft update, but the hit-or-miss nature of the problem, and the apparent corruption of the user’s Windows profile points a couple of fingers at a Microsoft update. I just don’t know which one.

 
Click to view/hide
 
Click to view/hide