Solved

Delete Mailbox account and create contact Powershell

Posted on 2014-03-18
7
371 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
Comment Utility
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
Comment Utility
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
Comment Utility
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 end users causing IT problems again?

You’ve taken the time to design and update all your end user’s email signatures, only to find out they’re messing up the HTML, changing the font and ruining the imagery. What can you do to prevent this? Find out how you can save your signatures from end users today.

 

Author Comment

by:gavintham
Comment Utility
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
Comment Utility
0
 

Accepted Solution

by:
gavintham earned 0 total points
Comment Utility
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
Comment Utility
full script
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

We are happy to announce a brand new addition to our line of acclaimed email signature management products – CodeTwo Email Signatures for Office 365.
Easy CSR creation in Exchange 2007,2010 and 2013
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…

763 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

10 Experts available now in Live!

Get 1:1 Help Now