[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 608
  • Last Modified:

Delete all Mailboxes in OU with Exchange 2007 Management Shell

Hello,
Looking for the command to fully delete all the Exchange Mailboxes contained in an OU.
0
adamant40
Asked:
adamant40
  • 3
2 Solutions
 
gupnitCommented:
Hi,
Here is your command:
ForEach ($mbx in Get-Mailbox -OrganizationalUnit YOUROU) { Remove-Mailbox -Identity $mbx -Permanent}  
Let me know
Thanks
Nitin Gupta (gupnit)
0
 
Rajith EnchiparambilOffice 365 & Exchange ArchitectCommented:
A simple one

get-mailbox -organizationalunit ouname | remove-mailbox -confirm$false

If you don't put -confirm$false, it will prompt you to review your decision.
0
 
adamant40Author Commented:
Hi Gupnit,
When I run
ForEach ($mbx in Get-Mailbox -OrganizationalUnit YOUROU) { Remove-Mailbox -Identity $mbx -Permanent}
It returns the error below. It seems very close, just missing a parameter. But I can't find it online.
Remove-Mailbox : Missing an argument for parameter 'Permanent'. Specify a param
eter of type 'System.Boolean' and try again.
At line:1 char:99
+ ForEach ($mbx in GET-Mailbox -OrganizationalUnit Test2) { Remove-Mailbox -Ide
ntity $mbx -Permanent} <<<<
Remove-Mailbox : Missing an argument for parameter 'Permanent'. Specify a param
eter of type 'System.Boolean' and try again.
At line:1 char:99
+ ForEach ($mbx in GET-Mailbox -OrganizationalUnit Test2) { Remove-Mailbox -Ide
ntity $mbx -Permanent} <<<<
0
 
adamant40Author Commented:
Hi Rajith,
When I run your command I get the error:
Remove-Mailbox : A parameter cannot be found that matches parameter name 'confi
rm$false'.
At line:1 char:69
+ get-mailbox -organizationalunit test2 | remove-mailbox -confirm$false <<<<
I will try to find the correct syntax.

0
 
adamant40Author Commented:
both answers needed tweeking but allowed me to get the task accomplished.
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now