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

Announcements

No record found.

News and Announcements icon
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
    Microsoft Employee 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,985 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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
ManoVerse Profile Picture

ManoVerse 101 Super User 2026 Season 1

#2
11manish Profile Picture

11manish 72

#3
Muhammad Shahzad Shafique Profile Picture

Muhammad Shahzad Sh... 69 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans