简体   繁体   中英

How to connect PowerShell with CRM online?

I am writing a PowerShell script where it needs to be connected to CRM online.

I can connect to CRM using Connect-CrmOnline where it asks for credentials using a login box. I want to automate it. Please guide on how to do it.

Is there a way to connect using connection string? Please share sample code/ script. I am new to PowerShell.

I am using Microsoft.Xrm.Data.PowerShell

Thank you.

You can build a credentials object and use that in the script. For example:

$secpasswd = ConvertTo-SecureString "PlainTextPassword" -AsPlainText -Force
$mycreds = New-Object System.Management.Automation.PSCredential ("username", $secpasswd)

You would then use it within your script with -credential $mycreds parameter

Ref: https://blogs.msdn.microsoft.com/koteshb/2010/02/12/powershell-how-to-create-a-pscredential-object/ and https://docs.microsoft.com/en-us/dynamics365/customer-engagement/developer/xrm-tooling/use-powershell-cmdlets-xrm-tooling-connect

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