Delete Exchange 2007 folder across all mailboxes

jcritzer
jcritzer used Ask the Experts™
on
So I'm under the impression this is impossible but let's give it a whirl...

We just setup an email archiving system called Proofpoint.  Part of this setup included running an OutlookFolderTool.exe file which Proofpoint provided us that created a subfolder under every user mailbox called "Archive by Proofpoint" which links to the website running on the appliance.

The problem lies in the fact that the home page for the newly created folder was setup to point to an HTTPS website when it needs to be pointing to an HTTP site, so nobody can currently get into the appliance to look at their archived emails.

Now, I'm no expert at either Powershell or VBS but nothing I have been able to come up with can either edit the properties of, or just plain delete, a subfolder under every mailbox across the organization.

I don't want to send out an organizational email to 800 users asking them to delete a subfolder because, under Murphy's Law and no matter how specific I am, people will invariably delete the wrong thing and I'll be doing restores for the rest of the month.

Any help GREATLY appreciated...
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Chris DentPowerShell Developer
Top Expert 2010

Commented:
Okay so it should be possible, but you have to be so very very careful with this (as I'm sure you're quite aware).

In theory... we can use Export-Mailbox to target a specific folder and do away with it. It would go something like this from the Management Shell:

Export-Mailbox "SomeMailbox" -IncludeFolder "/Archive by Proofpoint"  -DeleteContent

Extending that to all users goes:

Get-Mailbox | ForEach-Object {
  Export-Mailbox "SomeMailbox" -IncludeFolder "/Archive by Proofpoint"  -DeleteContent
}

Please test this very carefully first on mailboxes that do have the folder and mailboxes that don't. I imagine you could fabricate some of those easily enough :)

I reserve the right to have the syntax for Export-Mailbox wrong, I haven't got the Exchange tools here to test with. Check out Get-Help Export-Mailbox (-Full) for the options available.

Finally, if you can, export the folder to something else (another mailbox), that way if someone has been using it to store things you're safe because you can trivially get it back.

Chris

Author

Commented:
Running the following completes successfully in PS but does not actually delete the folder:

Export-Mailbox "user" -IncludeFolder "\Archive by Proofpoint" -DeleteContent
Chris DentPowerShell Developer
Top Expert 2010

Commented:
I may have the path to the folder wrong, you might try without the \, or switch it for /.

And if you could, pop something into the folder so we can see if it's finding the folder and deleting items, then simply failing to delete the folder itself.

Cheers,

Chris
Chris DentPowerShell Developer
Top Expert 2010

Commented:

Hmm although DeleteContent has a note that might render it quite useless: "The source folder isn't deleted". Still, let me know how you get on with the testing because at the moment I don't have a better alternative.

Chris

Author

Commented:
Running with / does not work.

And yes, it's clearing out the contents of the folder, not the folder itself.

Author

Commented:
Yep, this is the issue I've been running into for 48 hours now :)
Chris DentPowerShell Developer
Top Expert 2010

Commented:

It's annoying, I reckon it can be done with either MAPI or WebDAV but they're pretty irritating interfaces to work with for a non-programmer (like me).

All for need of Remove-MailboxFolder / Item.

Chris

Author

Commented:
I'm not a real programmer by any stretch of the imaginiation - usually editing scripts is the extent of it for me.

I know you can delete Outlook folder via the local profile with MFCMAPI.  Is there a way to script out the MAPI commands via VBS?  Maybe?
Chris DentPowerShell Developer
Top Expert 2010

Commented:
Hmm I'd be interested in testing the last method Shay decribes here:

http://www.vistax64.com/powershell/156862-deleting-folder-user-mailbox-exchange-2007-a.html

Depends how you feel about third-party tools really. I reckon we're a bit out of luck with native support or remotely easily accessible interfaces.

Do you ever feel the internal mailbox management has been slightly neglected in Exchange over the years? :)

Chris
Chris DentPowerShell Developer
Top Expert 2010

Commented:
> Is there a way to script out the MAPI commands via VBS?  Maybe?

I'd be really surprised if that wasn't possible. Alas my experience with the MAPI interface is limited to getting mailbox sizes from Exchange 2000, horribly out of date.

Chris

Author

Commented:
I stumbled across that post yesterday.  After trying to install RDO and feeling as if I was reinventing the wheel, I promptly gave up.

I use MAPI on occassion but I'm not familiar with its scriptability by any manner of speaking.  Maybe I should've included that forum with this post...

I'm still waiting on MS to release the most intuitive UI ever created for Exchange cmdlets..  After asking a few questions to generate the desired command, it says "You want to export these 13 mailboxes to storage group "HHGTTG," including only folders labeled 'Don't Panic!' and omitting all messages not 42k in size?  Sure!  No problem!"

Author

Commented:
Oh, cool, thanks.  Let's see if we have officially stumped the elite :)
Commented:
Scripting Guy Blog....

Const olFolderInbox = 6
Set objOutlook = CreateObject("Outlook.Application")
Set objNamespace = objOutlook.GetNamespace("MAPI")
Set objFolder = objNamespace.GetDefaultFolder(olFolderInbox)
strFolderName = objFolder.Parent
Set objMailbox = objNamespace.Folders(strFolderName)
Set objNewFolder = objMailbox.Folders("Archive by Proofpoint")
objNewFolder.Delete

Now I just need to figure out how to roll it out across the organization.  I'm not a fan of logon scripts.  It's always something :)
Chris DentPowerShell Developer
Top Expert 2010

Commented:

Damn, far too easy :) A nice find :)

You might check that on a system were multiple profiles are configured and outlook is prompting for a profile. Or are you free from those?

Execution... yeah logon scripts are no fun for this. Remote execution is not going to be too good, you'd need passwords for everyone.

It's annying really because you can access the mailbox centrally with CDO, but for knowing the deletion method.

Chris

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial