Solved

Delete Mailbox account and create contact Powershell

Posted on 2014-03-18
7
372 Views
Last Modified: 2014-04-12
I'm running MS exchange 2007.
I'm looking for a powershell script to delete bulk mailbox and create new contact.
however the new contact should include all the mailbox information (e.g. X500, smtp address, and user information such as phone number/title/etc)
0
Comment
Question by:gavintham
  • 4
  • 3
7 Comments
 
LVL 5

Expert Comment

by:arjunvyavahare
ID: 39936505
Hi,

To delete bulk mailboxes from Exchange 2007, refer:-

http://randomtechminutia.wordpress.com/2012/05/03/powershell-script-to-delete-exchange-mailboxes-in-mass/

To create bulk mailboxes in exchange 2007, refer:
http://blogs.technet.com/b/exchangept/archive/2007/10/04/bulk-creation-of-exchange-2007-mailboxes.aspx

I hope this will help you.

Regards,
Arjun
0
 

Author Comment

by:gavintham
ID: 39938726
Hi Arjun,

Thanks for you post.

I want to replace the user mailbox with new contact.

i want to retrieve all existing user mailbox detail out then perform delete.
after deleted then will create new contact of these users with the complete information.(e.g. X500, smtp address, and user information such as phone number/title/etc)

the article that you post only single solution. hope to hear you for more help.

Thanks
Gavin
0
 
LVL 5

Expert Comment

by:arjunvyavahare
ID: 39938808
Hi,

Try to run below command and see if you can get any clue:

get-mailbox -server Server_name -resultsize unlimited | get-user | select DisplayName, Title, Manager, Department | export-csv "c:\temp\info.csv"

Regards,
Arjun
0
Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

 

Author Comment

by:gavintham
ID: 39952476
hi Arjun,

if i want to export the complete information. (LegacyDN - x500, SMTP Address, DisplayName, Title, Manager, Department)

after that i need to to add all these information into new contact.

how to combine all these thing into a script?

Thanks
Gavin
0
 
LVL 5

Expert Comment

by:arjunvyavahare
ID: 39953161
0
 

Accepted Solution

by:
gavintham earned 0 total points
ID: 39968725
hi Arjun,

thank you for your advise. sorry to say that your solution is not completed.
anywhere i found it from other article and my program similar as below

foreach($Acc in $users)  
{
$userMailbox = get-mailbox $Acc -ResultSize Unlimited
$UserRecipient = get-recipient $Acc -ResultSize Unlimited
$UserAD = get-user $Acc -ResultSize Unlimited

$UserCompany = $userRecipient.company
If($UserCompany -eq $null){$UserCompany = ""}

$strOutput = $userRecipient.FirstName + "," +  $userRecipient.LastName + "," +  $userRecipient.displayname + "," + $userRecipient.name + "," + $userRecipient.Initials + "," + $userRecipient.alias  + "," + $userRecipient.PrimarySMTPAddress + "," +  $userreceipient.manager + "," +  $userRecipient.City + "," +  $userRecipient.PostalCode + "," +  $userRecipient.CustomAttribute1 + "," +  $userRecipient.CountryOrRegion + "," +  $userRecipient.Office + "," + $userRecipient.phone + "," + $userRecipient.StateOrProvince + "," + $userRecipient.ExternalEmailAddress + "," + $userRecipient.OrganizationUnit + "," + $UserMailbox.ForwardingAddress + "," + $UserMailbox.AcceptMessagesOnlyFrom + "," + $UserMailbox.AcceptMessagesOnlyFromDLMembers + "," +  $UserMailbox.LegacyExchangeDN + "," + $userRecipient.title + "," +  $userRecipient.department + "," + $UserAD.Fax + "," + $UserAD.HomePhone + "," + $UserAD.MobilePhone + "," + $UserAD.OtherFax + "," + $UserAD.OtherHomePhone + "," + $UserAD.OtherTelephone + "," + $UserAD.TelephoneAssistant + "," + ($UserCompany).toString()
}
0
 

Author Closing Comment

by:gavintham
ID: 39995845
full script
0

Featured Post

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We are happy to announce a brand new addition to our line of acclaimed email signature management products – CodeTwo Email Signatures for Office 365.
Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
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…

910 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now