By David Wiseman (Administrator)Created 04 Mar 2008
My Rating:
Not Rated

Search for All Users Having a Specified Exchange Server

Language:  PowerShell


Windows XP Yes Windows 2003 Yes
Windows 2000 No Windows NT No
Vista Unknown Windows 2008 Unknown

Sample script that searches Active Directory for all the users that have the Exchange server o=fabrikam/ou=First Administrative Group/cn=Configuration/cn=Servers/cn=atl-msg-01. The msExchHomeServerName attribute is replicated to the Global Catalog. This means you can connect to a Global Catalog server and search across the forest for users having a specified Exchange server. This attribute is available only if you have installed Microsoft Exchange.


Line Numbers: On  Off      Plain Text
$strFilter = "(&(objectCategory=User) `
    (msExchHomeServerName=/o=fabrikam/ou=First Administrative Group/cn=Configuration/cn=Servers/cn=atl-msg-01))"

$objDomain = New-Object System.DirectoryServices.DirectoryEntry

$objSearcher = New-Object System.DirectoryServices.DirectorySearcher
$objSearcher.SearchRoot = $objDomain
$objSearcher.PageSize = 1000
$objSearcher.Filter = $strFilter

$colProplist = "name"
foreach ($i in $colPropList){$objSearcher.PropertiesToLoad.Add($i)}

$colResults = $objSearcher.FindAll()

foreach ($objResult in $colResults)
    {$objItem = $objResult.Properties; $}


Got a useful script? Click here to upload!


  Post Comment
Order By:  
User Comments
Posted On: 9/19/2019 2:13:43 AM

Back in late 2012 I was looking for examples of WMI related System Information. I came across this HTA application and liked its layout. My environment is a company with several thousand employees. Most are in main offices but there are those working at home or at remote sites. google street view maps Being able to support employees when not able to connect to their system maybe through a VPN connection because of a router problem even though they can get to the internet is difficult to diagnose without some information. If you would like to see an enhanced version of the system information tool that is of a similar layout to this one but gives the capability to save the results to a report and then print that out you might be interested in mine. I have also developed a version that can be run as a remote task job such as from SCCM or Altiris. The "No_GUI" version of the application can be modified IN CODE to indicate the output folder location and which sections of information should be stored (reported). To make it able to output information to the usual GUI and be able to save it as an HTML report I have excluded certain features that were included in this product such as stopping process and mapping shares. Those features I will put in a version that is for SUPPORT Employees only. Since the HTML / VBScript code for the .HTA(s) is always a work in progress and has made it up to 300KB in size, I will not post the code here, but invite you to check the file out at or directly at

Posted On: 9/20/2019 3:41:18 PM

The script of power shell was big headache for me. Thanks for this prepared script which ease my college project. I find website very helpful in doing college projects to be completed on time.

Posted On: 10/9/2019 10:26:40 AM

So the training of the tools is not necessarily made you become a good multimedia designer. What is Graphic Design and Multimedia Design? street view

Posted On: 12/12/2019 7:28:23 AM

I love your blog! I am hoping to see more articles from you in the foreseeable future. Really great!!! helix jump

Posted On: 4/10/2020 6:28:47 AM

Specified servers can be found on numerous platforms of forums such as Dissertation Help UK I always found it useful for my choices.

Posted On: 6/5/2020 5:55:36 AM

Modify a Shadow Copy Storage Area is the main title that can be understand through this as it was one of the main things to learn from here. You can get to know about explore this info as it was legit. Apart from that there is nothing that can be done about it.

Posted On: 8/6/2020 10:36:54 AM

A very awesome blog post. We are really grateful for your blog post. You will find a lot of approaches after visiting your post. Mumbai Call Girls

Posted On: 8/10/2020 5:12:57 AM

I love this post here is good information for my new blogs thanks for sharing with us. Mumbai Escorts Service

Lisa King
Posted On: 8/24/2020 1:59:11 PM

Thank you for sharing this informative and useful coding. I read a similar post regarding the scripts at the best website of write my essay online. I’m so grateful to you for sharing this and increasing my knowledge of scripts.

Posted On: 9/10/2020 10:50:50 AM

The power shell script can be a headache for students. I read a similar solution in an article at buy assignments experts UK and they give me the same solution. Thank you for providing this prepared script to all of the students.

Posted On: 9/25/2020 8:42:44 AM

Play math game online. It's a fun puzzle number game. 2048