简体   繁体   中英

CRM Online - Create email server profile using Powershell

I need to configure email settings for a number of CRM online instances. I want to automate this as some of the sandbox environments will be reset periodically.

I have one instance configured manually (with our on prem exchange) so know what need to be done to get it working but I can't for the life of me seem to be able to retrieve and update the email server profile configuration. I either want to amend the default profile or create a new one.

I'm using the Microsoft.Xrm.Data.Powershell module so i'm able to retrieve entities and records but can't seem to find the specific data i'm after.

Has anybody done this before or able to point me in the right direction?

While I have never done this myself here are some ideas that might help:

The EmailServerProfile entity supports the typical CRUD messages, as well as specialized messages like GrantAccess, ModifyAccess, and RevokeAccess.

Options to run these from PowerShell would include:

  1. Use PowerShell to make requests to the D365 WebAPI, which will require OAuth2

  2. Install the Microsoft SDK Nuget Package(s) into PowerShell, load the appropriate assemblies, then create the .NET objects and run their methods. This post has more info on this type of approach.

  3. This package says it allows you to "invoke any available CRM request", so that might be worth looking into.

I checked this package , which has a lot of commands, including Approve-CrmEmailAddress and Revoke-CrmEmailAddress but did not see anything pertaining to EmailServerProfile.

Here is an example of how I create a fully working hybrid profile in on premise Dynamics installation:

New-CrmRecord -EntityLogicalName emailserverprofile -Fields @{
name                                    = "EmailProfile01"
servertype                              = [Microsoft.Xrm.Sdk.OptionSetValue]::new("3")
ownerid                                 = $ownerIdReference
exchangeonlinetenantid                  = $CRMContextId.Guid
useautodiscover                         = $true
incomingcredentialretrieval             = [Microsoft.Xrm.Sdk.OptionSetValue]::new("2")
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM