Get the Database where a user belongs to

In Exchange 2010 SP1 it is pretty simple to get the Database where a user belongs to (or a group of users given a list). We can achieve this with PowerShell quite quickly with the following command.

Where “ALIAS” is the alias of the user you’re searching for. The command will return the Alias and the Database name. If you’ve got a list of users you want to run through (you can import a list in an external text file, in this case just for the sake of showing you how to run through each object of a list, I’m using a variable where each alias is separated by a comma) just use the below.

The above will return you the Alias and the Database of alias1, 2 and 3. Note that in this specific case I used .split(“,”). I basically told it to split the list at every comma.
The % sign instead is the abbreviation of ForEach-Object$_ is the current alias being elaborated.

Leave a Reply

Your email address will not be published. Required fields are marked *