Category Archives: Exchange

Restoring deleted items from Public Folders natively

This morning I had a user call up and say that half the meeting room calendars (which are public folders) were empty. I checked via Exchange Management Console and could confirm that there were no items. However under the statistics for the folder, I noticed that it was showing a total deleted items size.

Deleted Items meeting room

I decided to check this out through ExFolders (Exchange 2010 replacement for PFDAVAdmin) and did come across a problem as I was getting the error “An error occurred while trying to establish a connection to the exchange server. Exception: the Active Directory user wasn’t found”. To get past this issue open ADSIEDIT and select Configuration from the Well Known Naming Context drop down menu. Then drill down to Configuration> Services> Microsoft Exchange> Domain Name> Administrative Groups> First Administrative Group> and then delete the Servers object. This can sometimes be left behind from old Exchange 2003 installs. As soon as that is gone then ExFolders can continue (please read the “read me” for ExFolders as it does specify to run the reg edit file and also to move ExFolders.exe to your Exchange location\bin\ folder, which is generally in <drive>:\Program Files\Microsoft\Exchange Server\V14\Bin. It will crash otherwise).

ExFolder Deleted contents

After finding one of the folders that had its content deleting I noticed that at the bottom, there is a “normal contents” and “deleted contents” radio buttons. Unsurprisingly, selecting “deleted contents” brings up the list of deleted items. To restore them it is a simple task of selecting the items, right clicking and selecting “restore items”. Bingo the items are back and I didn’t even need to get out of my chair to get to the backup tapes. Which is handy as it is in the opposite direction to the pub…


Find email address in Public Folders

Looking after several thousand mailboxes, public folders and distribution groups can sometimes make it difficult for you to keep track on where certain email aliases are assigned.

Now mailboxes, distribution groups and mail contacts are easy as you can add a filter in the Exchange Management Console to find these, however the same cannot be applied for Public folders.

Once again PowerShell comes to the rescue in the form of the Exchange Management Shell. Running the following command will bring up all the details you need:

Get-MailPublicFolder | Get-PublicFolder

This command will bring up the name of the public folder along with the parent path so you know exactly where the public folder lives by showing the folder name and the parent path so you can navigate to the folder in question.

output from Get-MailPublicFolder

Not only do you get to find the public folder you get to learn a little more about Power Shell with the nice “Tip of the day” that appear in the Exchange Management Shell

Now that deserves a beer!

Create new mail contacts from a CSV file for Exchange 2007/2010

Today I had a colleague come to me, asking for help as she had a user asking to have 649 mail contacts created and added to a distribution group by the end of the day.

Now instead of sitting there and slowly adding in each and every single contact individually (which if you’ve had to do this before in Exchange you’ll know it’s an absolute nightmare!!) I decided to modify a script I wrote a while back for importing mailboxes from a CSV file.

So the format of the CSV file should be:

Name Email OUPAth
Test User domain.local/Mail Contacts/Test

For the OUPath you can easily find this out by going into your Active Directory and right clicking on the folder you wish the mail contacts to be imported into, and going to Properties
OU Properties

As you can see in the Object section you can find out the OU Path, by looking at the Canonical name of object:

Once the .CSV file is created and formatted correctly you can use this wonderful little powershell script I wrote:

Import-CSV C:\createnewcontact.csv | ForEach-Object{
New-MailContact -ExternalEmailAddress $_.Email -Name $_.Name -OrganizationalUnit $_.OUpath

Now I’ll talk you through section by section on what this script does so you’re a little more aware (and i can prove I didn’t just copy and paste from a website :p)

Now “Import-CSV C:\createnewcontact.csv” basically tells Powershell to import data from the CSV file which lives directly on the C:\ and is called createnewcontact.csv (bare in mind if you call your CSV differently you will need to change this section)

“ForEach-Object”{ allows you to perform an action on each item in the collection (in this case everything between the { }

“New-MailContact” This is kind of self-explainatory to be honest. If you want a new mailbox you put in New-Mailbox and for a new mail contact you use New-MailContact

Now when you run New-MailContact manually into PowerShell it asks you for 2 pieces of information:

  • ExternalEmailAddress
  • Name

So when your PowerShell script runs New-MailContact it still needs this information. So by using “-ExternalEmailAddress$_.Email” you are telling the script that when it gets asks what the -ExternalEmailAddress is the PowerShell sees $_.Email which signifies to it that it should get this information from the Email column ($_. tells it to use the column and the name after it is the column name)

This is the same for -Name $_.Name -OrganizationalUnit $_.OUpath

I’m not the greatest at explaining things so I do apologise. If in doubt just copy exactly what I’ve done and you’ll be fine 🙂

Mailcontact Powershell

Pop in the location of the script into Power Shell (or if you’re really lazy just drag and drop the script from Explorer into the Power Shell window) and hit enter and watch it run away and create hundreds of mail contacts from your .CSV file in seconds…and then have a beer