Trying to automate the configuration of our mailboxes utilizing the Exchange Scripting Agent. I can successfully configure the basic settings
of the mailbox, but fail when trying to call another powershell script (Create-MailboxFolder)
that creates a "Voicemail" folder within the users mailbox utilizing EWS. NOTE: The Create-MailboxFolder script runs successfully (manually) outside the Exchange Scripting Agent.
The Create-MailboxFolder script is failing with multiple errors when called with the Exchange Scripting Agent, but the first is the Impersonation
Rights (I think). "Access is denied. Check credentials and try again." RE: the Create-MailboxFolder script...it does have to run within an EMS and requires impersonation rights be configured for the user running it.
Can anyone help point me in the right direction?
_____________________________________________________________________________________
ScriptingAgentConfig.xml
XML
<?xml version="1.0" encoding="utf-8" ?>
<Configurationversion="1.0">
<FeatureName="MailboxProvisioning"Cmdlets="New-Mailbox,Enable-Mailbox">
<ApiCallName="OnComplete">
if($succeeded)
{
Start-Sleep -Seconds 30
$dc = [string]($readOnlyIConfigurable.originatingserver)
if($provisioningHandler.UserSpecifiedParameters["Identity"] -ne $null)
{
$name = $provisioningHandler.UserSpecifiedParameters["Identity"].ToString()
}
elseif($provisioningHandler.UserSpecifiedParameters["Name"] -ne $null)
{
$name = $provisioningHandler.UserSpecifiedParameters["Name"].ToString()
}
else
{
$name = $provisioningHandler.UserSpecifiedParameters["Alias"].ToString()
}
Set-Mailbox -Identity $name -RetentionPolicy "Default MRM Policy" -DomainController $dc.DOMAIN.local
Set-CASMailbox -Identity $name -ActiveSyncEnabled $false -OWAEnabled $false -OWAforDevicesEnabled $false -ImapEnabled $false -PopEnabled $false -DomainController $dc.DOMAIN.local
$mailbox = Get-Mailbox -Identity $name | Select-Object -ExpandProperty primarysmtpaddress | %{[string]$x=$_;$x}
C:\Scripts\Create-MailboxFolder.ps1 -Mailbox $mailbox -RequiredFolders "Voicemail" -ParentFolder "\"
}
</ApiCall>
</Feature>
</Configuration>
_____________________________________________________________________________________
Error Log from Create-MailboxFolder.ps1
Using default credentials Attempting to bind to folder MsgFolderRoot (TestUser@DOMAIN.local)
Error occurred attempting to bind to folder: Exception calling "Bind" with "2" argument(s): "Access is denied. Check credentials and try again., " Attempting to bind to folder Error occurred attempting to bind to folder:
Exception calling "Bind" with "3" argument(s): "Value cannot be null. Parameter name: folderId" Checking for existence of Voicemail in Attempting to bind to folder Error occurred attempting to bind to folder: Exception
calling "Bind" with "3" argument(s): "Value cannot be null. Parameter name: folderId" GetFolder: root folder is GetFolder: requested folder path is Voicemail