Autodiscover and Client-only Sites (Revisited)

Previously I had posted a problem regarding Autodiscover site-scoping and client-only sites.  For sites that do not have Exchange Servers in them, the corresponding client sites must be added to the SCP object so that Outlook clients will discover the closest Client Access Servers for Autodiscover.

I want to call out one issue I was informed about that one customer had run into (but most folks likely won't).  There actually is an upper-limit to the maximum number of values (or actually overall size) of a multi-valued attribute in Active Directory.  For these site values that limit typically exists somewhere between 800-900 entries. 

The error returned is:

Set-ClientAccessServer : Active Directory operation failed on This error is not retriable. Additional information: The administrative limit for this request was exceeded. Active directory response: 00002024: SvcErr: DSID-02080490, problem 5008 (ADMIN_LIMIT_EXCEEDED)

In this case, the customer had multiple load-balanced CAS's in any given site.  He simply split up the assignment and put 400 Sites in one SCP and 400 Sites in the other.  It seems that this is likely the best workaround if you were to run into this.


On another note, I found out something really cool you could do with Powershell today and wanted to update my previous script post so that it is 100% Powershell.  I was under the impression that you could not call Win32 API's from Powershell; while that is technically accurate, you can call Win32 API's from C# and you can call C# from Powershell so guess what you get?  Dynamically compiled C# code to call the Win32 API embedded in and invoked from a Powershell script!

This is adapted from the following blog post: Powershell - PINVOKE or accessing WIN32 APIs

The main script is identical to the script I previously posted.  However, this time instead of calling the command-line EXE, I call my .NET static method that I defined previously.


First: A Compile-CSharp function to do the on-the-fly compilation of my C# source code

We create a new instance of the CSharp code provider to do the compilation.


We then set our parameters for the compilation operation.


$cpar.GenerateInMemory =$true

$cpar.GenerateExecutable =$false

$cpar.OutputAssembly ="custom"

Then we compile the source.

$cr=$cp.CompileAssemblyFromSource($cpar, $code)


Second: Defining the C# code and calling the compilation function


<C# code here>


# Compile our C# code for doing the site cost calculations




Finally: Calling the managed static method defined in our C# Code

[int[]] $costArray=$null;


$siteCostStatus= [SiteCost.SiteCostLib]::QuerySitesByCost($clientsite.Name, $exchangeSites, [ref]$costArray);


NOTE: At this time the download is not available.  I am trying to locate the script and will repost it if/when I can find it.


Skip to main content