web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Suggested Answer

Unable to login to CRM using powershell commands from Run book

(0) ShareShare
ReportReport
Posted on by 87

Hi Team,

I need to connect Dynamics 365 instance from Azure Runbook. To do that I have prepared below commands, which are working fine to connect to Dynamics CRM from my local Power shell command prompt. 

However when I am executing the command from Azure Runbook, it is throwing below error. Kindly help me to sort out the issue. Thanks!!

Command used to connect to CRM:

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$user = "abc@zyz.com"
$passwordConverted = ConvertTo-SecureString "*******" -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential ($user, $passwordConverted)
$serverhost = "Dyanamics123.crm.dynamics.com"
$CRMConn = Get-CrmConnection –ServerUrl Dyanamics123.crm.dynamics.com -Credential $Cred -OrganizationName Dyanamics123
Write-Host "Connection info $connection"
$request = new-object Microsoft.Crm.Sdk.Messages.WhoAmIRequest
$CRMConn.Execute($request)

Error:

Failed to connect to CRM: BadConnect
Failed to connect to CRM: Exception while trying to connect Discovery Server,
(Global Discovery) URI is = globaldisco.crm.dynamics.com/.../InstancesNo Orgs Found, Searched Online. Region Setting = NorthAmerica

Regards,

Venkatesh

I have the same question (0)
  • Suggested answer
    Pradeep Rai Profile Picture
    5,489 Moderator on at

    Hi Venkatesh,

    Please check below link:
    https://www.youtube.com/watch?v=yWwsEjwzEoA

    Thanks,
    Pradeep.

  • Venkateshpilla Profile Picture
    87 on at

    Hi Pradeep,

    Thanks for quick response and sharing the link. But it does not have the content to connect to CRM from runbook. I have issue in establishing the connection to CRM from Azure Runbook.

    Regards,

    Venkatesh

  • Suggested answer
    Kenneth Ariel Chaves Herrera Profile Picture
    on at

    Hi,

    Try with these instructions:

    Use PowerShell cmdlets for XRM tooling to connect to Dynamics 365 Customer Engagement (on-premises) (Developer Guide for Dynamics 365 Customer Engagement) | Microsoft Docs

    If this was helpful, please check it as verified to help others finding useful information.

    Welcome to this amazing community.

  • Venkateshpilla Profile Picture
    87 on at

    Hi Kenneth,

    Thanks for your reply.

    Seems the link is used to Connect to CRM On premise version, however, I need to connect to CRM Online . Could you Please provide me the links to connect to CRM Online, if avaialable.

  • Suggested answer
    Bipin D365 Profile Picture
    28,983 Moderator on at

    Hi,

    Have you tried updating XRMTooling Module by executing below script?

    Update-Module -Name Microsoft.Xrm.Tooling.CrmConnector.PowerShell

    Set the execution policy to run the signed PowerShell scripts. To do so, open a PowerShell window as an administrator and run the following command: Set-ExecutionPolicy -ExecutionPolicy RemoteSigned

    I think you are missing DeploymentRegion and OnlineType parameters to connect to dynamics crm online instance -

    docs.microsoft.com/.../use-powershell-cmdlets-xrm-tooling-connect

    $CRMConn = Get-CrmConnection -Credential $Cred -DeploymentRegion <Deployment region name> –OnlineType Office365 –OrganizationName <OrgName>

    Please mark my answer verified if this is helpful!

    Regards,

    Bipin Kumar

    Follow my Blog: xrmdynamicscrm.wordpress.com/

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 170 Super User 2025 Season 2

#2
#ManoVerse Profile Picture

#ManoVerse 70

#3
Jimmy Passeti Profile Picture

Jimmy Passeti 50 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans