Solved

Powershell script to disconnect Exchange 2003 mailboxes not working

Posted on 2010-09-17
3
945 Views
Last Modified: 2012-05-10
I'm using a script that I found at PowerGui.org website but I'm running into problems. I tested the script in a test environment with Exchange 2003 installed on the DC, and the script worked just fine. However, when I run the script from my Win7 machine in my production network to delete mailboxes on my Exchange 2003, I run into problems saying that there was a problem with the "deletemailbox" method. Any idea what I'm missing? I'm including the script and a snapshot of the error message.

http://www.powergui.org/thread.jspa?messageID=33010
$strDCName = "SERVER1"



Import-Csv "c:\myfile.csv" | `

ForEach {

	#$dn = (Get-QADUser -identity $Username | Select-Object dn).dn

	$today = $(Get-Date).ToShortDateString()

	$name = $_.DisplayName

	$dn = (Get-QADUser -Identity $_.NTAccountName | Select-Object DN).dn

	$homeMDB = (Get-QADUser -Identity $_.NTAccountName -IncludedProperties homeMDB | Select-Object homeMDB).homeMDB

	

	$user = [adsi]("LDAP://$strDCName/$dn")



	if ($homeMDB -eq $null) {

		Write-Host "User does not have a mailbox"

		}



	else {

		$user.DeleteMailbox()

		$user.Description = "Disconnected mailbox via script, $today"

		$user.SetInfo()

		Write-Host "Deleted mailbox for $name"

		}

}

Open in new window

error-disconnecting-mailbox.png
0
Comment
Question by:bndit
  • 2
3 Comments
 
LVL 70

Accepted Solution

by:
Chris Dent earned 500 total points
ID: 33707115

You must have the Exchange 2003 tools installed on the host. This script requires CDOEXM.

Chris
0
 
LVL 2

Author Comment

by:bndit
ID: 33719219
As always, thanks Chris. I'll award you the points as you answered my question...However, what would you suggest to accomplish the same goal without having to install the Exchange 2003 tools? Installing the Exchange 2003 is a bit messy on Windows 7, and I'd like to disconnect mailboxes without having to install them, if possible.
0
 
LVL 2

Author Closing Comment

by:bndit
ID: 33719227
Thx for the quick reply
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Are you one of those front-line IT Service Desk staff fielding calls, replying to emails, all-the-while working to resolve end-user technological nightmares? I am! That's why I have put together this brief overview of tools and techniques I use in o…
In this previous article (https://oddytee.wordpress.com/2016/05/05/provision-new-office-365-user-and-mailbox-from-exchange-hybrid-via-powershell/), we made basic license assignments to users in O365. When I say basic, the method is the simplest way …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

746 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

13 Experts available now in Live!

Get 1:1 Help Now