I tried to use cmdlet scripting agent to update some mailbox settings after New-Mailbox or Enable-Mailbox in a single-site/multi-domains environment. I am getting "Microsoft.Exchange.Provisioning.ProvisioningException: ScriptingAgent: Exception thrown while invoking scriptlet for OnComplete API: Cannot open mailbox /o=CITY/ou=Exchange Administrative Group (FYDIBOHF23SPDLT)/cn=Configuration/cn=Servers/cn=COWSVPEMM3/cn=Microsoft System Attendant.. ---> Microsoft.Exchange.Data.Storage.ObjectNotFoundException: Cannot open mailbox" and I think this is due to replication delay. I tried to use [string]($readOnlyIConfigurable.originatingserver) to obtain the DC used in the session, so I can force the script to use the same DC but ($readOnlyIConfigurable.originatingserver) return a blank value. Does that make sense? Is there any other way to retrieve the DC info?
thanks