Solved

Delete Mailbox account and create contact Powershell

Posted on 2014-03-18
7
375 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Exchange 2010 EMC access 6 36
Exchange Server 2016 Installation 2 17
EXCH2013 IIS 4 14
Does exchange server encrypt my email? 10 35
Marketers need statistics and metrics like everybody else needs oxygen. In this article we explain how to enable marketing campaign statistics for Microsoft Exchange mail.
This article explains how to install and use the NTBackup utility that comes with Windows Server.
The basic steps you have just learned will be implemented in this video. The basic steps are shown to configure an Exchange DAG in a live working Exchange Server Environment and manage the same (Exchange Server 2010 Software is used in a Windows Ser…
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…

831 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