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 85

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

  • Suggested answer
    Bipin D365 Profile Picture
    Bipin D365 28,961 Moderator on at
    RE: Unable to login to CRM using powershell commands from Run book

    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/

  • Venkateshpilla Profile Picture
    Venkateshpilla 85 on at
    RE: Unable to login to CRM using powershell commands from Run book

    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
    RE: Unable to login to CRM using powershell commands from Run book

    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
    Venkateshpilla 85 on at
    RE: Unable to login to CRM using powershell commands from Run book

    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
    Pradeep Rai Profile Picture
    Pradeep Rai 5,482 Super User 2025 Season 1 on at
    RE: Unable to login to CRM using powershell commands from Run book

    Hi Venkatesh,

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

    Thanks,
    Pradeep.

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,387 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans