[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Powershell script to disconnect Exchange 2003 mailboxes not working

Posted on 2010-09-17
3
Medium Priority
?
960 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 71

Accepted Solution

by:
Chris Dent earned 2000 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

Are You Ready for GDPR?

With the GDPR deadline set for May 25, 2018, many organizations are ill-prepared due to uncertainty about the criteria for compliance. According to a recent WatchGuard survey, a staggering 37% of respondents don't even know if their organization needs to comply with GDPR. Do you?

Question has a verified solution.

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

In threads here at EE, each comment has a unique Identifier (ID). It is easy to get the full path for an ID via the right-click context menu. However, we often want to post a short link within a thread rather than the full link. This article shows a…
In the absence of a fully-fledged GPO Management product like AGPM, the script in this article will provide you with a simple way to watch the domain (or a select OU) for GPOs changes and automatically take backups when policies are added, removed o…
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Suggested Courses

650 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