Improve company productivity with a Business Account.Sign Up

x
?
Solved

Exchange 2007 PowerShell commmand to move mailbox to .pst AND delete the mailbox from AD?

Posted on 2009-05-12
7
Medium Priority
?
866 Views
Last Modified: 2012-05-06
Hello,
Hoping to find a PowerShell command to export a user's mailbox to a .pst AND delete the mailbox from AD. I've tried -DeleteContent -verbose and it seems to delete all the mail, but leave the mailbox. Ultimately I want to run this command on all users in an OU.
Thank you.
0
Comment
Question by:adamant40
  • 3
  • 3
7 Comments
 
LVL 24

Accepted Solution

by:
Rajith Enchiparambil earned 1000 total points
ID: 24369592
export-mailbox -identity username -pstfolderpath c~:\user.pst

remove-mailbox -identity username
0
 

Author Comment

by:adamant40
ID: 24369832
Hi Rajith,
My goal is to be able to run this on mailboxes in an OU. Could you give me the specific command structure for exporting all the mailboxes in OU Test to .pst files and deleting the mailboxes from AD? I've tried a few different ways of implementing your command but have not succeeded. Thank you.
0
 
LVL 24

Expert Comment

by:Rajith Enchiparambil
ID: 24369915
get-mailbox -organizationalunit ouname | export-mailbox -pstfolderpath c~:\user.pst
0
Making Bulk Changes to Active Directory

Watch this video to see how easy it is to make mass changes to Active Directory from an external text file without using complicated scripts.

 

Author Comment

by:adamant40
ID: 24369967
Hi Rajith,
get-mailbox -organizationalunit ouname | export-mailbox -pstfolderpath c~:\user.pst is the command I use to export all the mailboxes into .pst files. BUt it doesn't delete the mailbox from the mail store. Is there one command to do that? If not, is there a command to delete all mailboxes in an OU?
I could run get-mailbox -organizationalunit ouname | export-mailbox -pstfolderpath c~:\user.pst first, then the 2nd command to delete the mailboxes. That would be almost as good. Thank you.
0
 
LVL 32

Assisted Solution

by:gupnit
gupnit earned 1000 total points
ID: 24371388
Hi,
Here are your commands:
  • Export all Mailboxes in OU:Get-Mailbox -OrganizationalUnit YOUROU | Export-Mailbox -PSTFolderPath C:\PSTFiles
  • Delete All Mailboxes & Account in OU: ForEach ($mbx in Get-Mailbox -OrganizationalUnit YOUROU) { Remove-Mailbox -Identity $mbx -Permanent}
Let me know
Thanks
Nitin Gupta (gupnit)
0
 
LVL 24

Expert Comment

by:Rajith Enchiparambil
ID: 24372170
Simple command.

get-mailbox -organizationalunit ouname | remove-mailbox -confirm:$false

Give $true if you want to be prompted for approval.
0
 

Author Closing Comment

by:adamant40
ID: 31580735
This was great information and worked with minor tweaking. Thanks all.
0

Featured Post

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Disk errors can be the source of sundry problems for the Exchange server, the most common one being that the database fails to mount.
Are you working to mount the dismounted Exchange 2013 database? Then the best course of action is to analyze the causes of Database issue, their probable solutions and decide for the appropriate course of action.
This video demonstrates how to sync Microsoft Exchange Public Folders with smartphones using CodeTwo Exchange Sync and Exchange ActiveSync. To learn more about CodeTwo Exchange Sync and download the free trial, go to: http://www.codetwo.com/excha…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

608 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question