Welcome to MSDN Blogs Sign in | Join | Help

How to set the msExchQueryBaseDN attribute for users via powershell

I was working in the lab today trying to debug a reproduction of an OWA hosting issue and I had the need to set the msExchQueryBaseDN for 10,000 users. Typically you can use Poweshell with the get-user | set-user commands to access mailbox properties for stamping purposes, however the msExchQueryBaseDN attribute is a user based attribute. Here are two ways you can do it:

How to set an attribute for one user via powershell
$user = ([ADSI]"LDAP://OU=MyOU,DC=Company,DC=com").psbase;
$user.Properties["msExchQueryBaseDN"].Value = "CN=User,OU=MyOU,DC=Company,DC=com";
$user.CommitChanges();

How to set an attributes for a group of users in an OU via Powershell
get-mailbox userName* -resultsize unlimited | Foreach { $dn = "LDAP://" + $_.distinguishedname;$obj = [ADSI]$dn;$obj.msExchQueryBaseDN = "OU=YourOU,DC=company,DC=com";$obj.setinfo()}

This little bad boy stamped 10,000 users in less than 2 minutes.

Dave

Published Thursday, January 08, 2009 12:15 PM by dgoldman

Comments

Friday, January 09, 2009 2:28 PM by subject: exchange

# Weekend reading

What is Exchange 2007's Last Log Resilience? Can I seed a cluster continuous replication passive

Thursday, March 19, 2009 10:01 PM by MarkyD

# re: How to set the msExchQueryBaseDN attribute for users via powershell

Kudos to Dave for this article and the PS command.  This fixed my customer's issue.  

New Comments to this post are disabled
 
Page view tracker