Script agent - problem with domain controllers.
Hello. I'm trying to enforce some policies (in particular, assigning address book policies and disabling OWA/Activesync) on our mailboxes using script agent. I'm using scripting agent configuration like this: <Feature Name="MailboxProvisioning" Cmdlets="enable-mailbox,new-mailbox"> <ApiCall Name="OnComplete"> if($succeeded) { if ($provisioningHandler.UserSpecifiedParameters["Identity"] -ne $null) {$user = $provisioningHandler.UserSpecifiedParameters["Identity"].ToString()} else {$user = $provisioningHandler.UserSpecifiedParameters["Name"].ToString()} if($provisioningHandler.UserSpecifiedParameters["AddressBookPolicy"] -eq $null) { Set-Mailbox $user -AddressBookPolicy ABP_Default } Set-CasMailbox $user -OWAEnabled $false -ActiveSyncEnabled $false } </ApiCall> The problem is that we have three domain controllers in the AD site. So, if I use new-mailbox cmdlet immediately followed by set-mailbox (or any other mailbox or user operation), Exchange can query different domain controllers. AD replication isn't instant, and I got errors because cmdlet cannot find AD object. If I configure all setting by himself, I can use Set-ADServerSettings cmdlet, and all queries in single powershell session will be done to one DC. But mailbox tasks in our organization can be done by different people in different ways, so I want to use scripting agent to enforce correct settings. Is there any way to tell scripting agent to use the same DC in affected cmdlets and in agent's script blocks? The only way that I can think of is to use Set-ExchangeServer to set static DC configuration, but I want to avoid such extreme thing.
September 19th, 2012 5:11am

Yes, I know, but this parameter has to be manually specified. As I said, mailbox tasks can be done by different people in different ways. People can be lazy or forgetful, scripts can't. I want to be sure that correct setting will be enforced even if cmdlets are invoked without full set of correct parameters. I can pass some predefined mailbox properties to cmdlets using "ProvisionDefaultProperties" part of the scripting agent config, but I don't know how to pass -DomainController parameter.
Free Windows Admin Tool Kit Click here and download it now
September 19th, 2012 5:33am

Hello ildarz, If you want to set default domain controller in script, you can just follow Steves suggestion to add the domain controller in script. $Domaincontroller="DC.contoso.com" Set-mailbox -DomainController $Domaincontroller If you need users use the same domain controller in different ways, you can set Exchange to use the static domain controller. Thanks, Evan Liu TechNet Subscriber Support in forum If you have any feedback on our support, please contact tnmff@microsoft.com Evan Liu TechNet Community Support
September 20th, 2012 5:06am

Hi It's exactly as Evan said, create a $Domaincontroller variable at the beginning of the script and then include the -Domaincontroller $domaincontroller parameter as part of every new- or set- command. Cheers, Steve
Free Windows Admin Tool Kit Click here and download it now
September 20th, 2012 6:44am

Thanks for answers. Let me clarify my question. I use "ProvisionDefaultProperties" and "OnComplete" API calls in the scripting agent to customize behaviour of Exchange cmdlets. I want to know two things: 1. If customized cmdlet can accept -DomainController parameter, is there some way to pass it's value through "ProvisionDefaultProperties" API Call (like I can pass different mailbox properties)? 2. Is it possible to see in "OnComplete" API call which DC was actually used by customized cmdlet (new-mailbox for example)? If it is not possible then I'll think about other way. Also, are there any detailed guides about scripting agent? This and configuration file example from Exchange installation isn't very thorough...
September 20th, 2012 11:56am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics