none
FIM PowerShell MA -Export Error RRS feed

  • Question

  • Hi Experts,

    I created a PSMA to connect to Exchange Online and perform some updates. Although it performs the updates, I get ma-extension-error in my Sync console and in the event viewer I get the below:

     

    The extensible extension returned an unsupported error.
     The stack trace is:

     "Microsoft.MetadirectoryServices.ExtensionException: csEntry ID: 0e16fbd1-514b-e711-80f0-00155d01020d, Export unsuccessful. 
       at Microsoft.IdentityManagement.Connector.PowerShell.Bridge.ExportBridge.PutExportEntries(String scriptFileConfigKey, IList`1 connectorSpaceEntries)
    Forefront Identity Manager 4.4.1302.0"

    Below is my Export Script:

                                                                                                                      

     [CmdletBinding()]            
    param            
    (                
        [ValidateNotNull()]            
        [System.Collections.ObjectModel.KeyedCollection [string,Microsoft.MetadirectoryServices.ConfigParameter]] $ConfigParameters,            

        [System.Management.Automation.PSCredential] $PSCredential,            

        [System.Collections.Generic.IList[Microsoft.MetaDirectoryServices.CSEntryChange]] $CSEntries,            

        [Microsoft.MetadirectoryServices.OpenExportConnectionRunStep] $OpenExportConnectionRunStep,            

        [Microsoft.MetadirectoryServices.Schema] $Schema            
    )            

    Set-StrictMode -Version 3.0    

    Import-Module (Join-Path -Path ([Microsoft.MetadirectoryServices.MAUtils]::MAFolder) -ChildPath 'FIMPowerShellConnectorModule.psm1') -Verbose:$false -ErrorAction 'Stop'
    $Username = "username@contoso.com"
    $SecurePassword = ConvertTo-SecureString "########" -AsPlainText -Force
    $mycreds = New-Object System.Management.Automation.PSCredential ($Username, $SecurePassword)
    $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $mycreds -Authentication Basic -AllowRedirection
    $null = Import-PSSession $Session
    $exportResults = New-Object Microsoft.MetadirectoryServices.PutExportEntriesResults

    foreach($CSEntry in $CSEntries) {
        $logMessage = ""            
        switch ($CSEntry.ObjectType) 
        {            
            'user' 
            {  
                $guid = $CSEntry.Identifier
    #$guid | Out-File C:\SharedMailboxPermissionMA\PS.txt -Append
    $cloudAnchor = $CSEntry.AnchorAttributes['userPrincipalName'].Value.ToString()
    switch ($CSEntry.ObjectModificationType)
                {            
                    'Update'
                    {
                        if($CSEntry.AttributeChanges.Contains('SendOnBehalfOf'))
                        {
    foreach($sendOnBehalfOf in $CSEntry.AttributeChanges['SendOnBehalfOf'].ValueChanges)
    {
    $User = $sendOnBehalfOf.Value 
    $OperationType = $sendOnBehalfOf.ModificationType 
    if($OperationType -eq 'Add')
    {
    Set-Mailbox -Identity $cloudAnchor -GrantSendOnBehalfTo @{add=$User}
    }

    if($OperationType -eq 'Delete')
    {
    Set-Mailbox -Identity $cloudAnchor -GrantSendOnBehalfTo @{remove=$User}
    }
    }
    }

                    }

                    default  {
    #[System.Diagnostics.EventLog]::WriteEntry("FIMSynchronizationService", "In Default", [System.Diagnostics.EventLogEntryType]::Information, 221)
                        $csentryChangeResult = [Microsoft.MetadirectoryServices.CSEntryChangeResult]::Create($guid, $null, [Microsoft.MetadirectoryServices.MAExportError]::Success)
                        $exportResults.CSEntryChangeResults.Add($csentryChangeResult)

                    }          
                }            
            }            
        }            
    }      

    Write-Output $exportResults 

    I went through some of the Tech Net articles which was related to this error but nothing worked for me. Any help is appreciated. Thanks!!


    Veena

    Thursday, June 8, 2017 12:17 PM

All replies

  • Any suggestions/thoughts?

    Veena

    Friday, June 9, 2017 1:12 PM
  • I was finally able to solve this issue.

    I had to append |Out-Null at the end of each PS cmdlet that was making call to EXO.

    Thanks!


    Veena

    • Proposed as answer by Suryendu Friday, November 15, 2019 9:43 PM
    Tuesday, June 20, 2017 8:33 AM
  • Hi Veena ,

    Completely unrelated but I was working on an azure ad mim integration scenario and toying with the idea of working with PSMA. (I am little late in the party). However I was finding it difficult to  find a nice yet simple example. Your code helped.

    Thanks

    Suryendu 

    Friday, November 15, 2019 9:43 PM