How to connect d365 current using Powershell script.

 Install the "Microsoft.Xrm.Data.PowerShell" module:

Open PowerShell and import the module with the following command if it's not already imported:

Install-Module Microsoft.Xrm.Data.PowerShell -Scope CurrentUser

There is a small issue with the command you provided. The correct parameter name for setting the execution policy is "ExecutionPolicy," not "–ExecutionPolicy." 

Here's the correct version of the command:

Set-ExecutionPolicy –ExecutionPolicy RemoteSigned –Scope CurrentUser

The command you provided is used to set the security protocol used by .NET's ServicePointManager. Specifically, it sets the security protocol to TLS 1.2, 

which is a more secure version of the TLS (Transport Layer Security) protocol used for secure communications over a computer network.

[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12

Define your CRM connection parameters:

You'll need to gather some information to connect to your CRM instance. The parameters required are:

$Username="APY***@Trailcrm.com"

$Password="apy****"

$pwd = ConvertTo-SecureString $Password -AsPlainText -Force 

$credentials = New-Object System.Management.Automation.PSCredential($Username, $pwd)

$CRMConnection = Connect-CrmOnline -Credential $credentials -ServerUrl "https://apytrailcrm****.crm.dynamics.com/" -ForceOAuth

Get-CrmConnection: This cmdlet is from the "Microsoft.Xrm.Data.PowerShell" module, which allows you to connect to a Dynamics 365 CRM instance from PowerShell.

-InteractiveMode: This parameter specifies that the cmdlet should interactively prompt the user to provide credentials for connecting to the CRM instance. 

When you use this parameter, PowerShell will display a prompt to enter the CRM URL, username, and password.

$conn = Get-CrmConnection -InteractiveMode

Comments

Popular posts from this blog

Meta Data Using WebApiRequest

Sample CRUD Operations Using C# in MSCRM

Basic Plugin Code in D365 using C#