Posted on 4 Comments

The specified module ‘MSAL.PS’ was not loaded because no valid module file was found in any module directory.

Recently when I used Dynamics 365 Finance and Operation tools plugin for Azure Devops I faced an issue with a missing Powershell module.

Error message:

##[error]The specified module 'MSAL.PS' was not loaded because no valid module file was found in any module directory.

In order to bypass this issue, add a PowerShell step with the below commands:

Set-PSRepository PSGallery -InstallationPolicy Trusted
Install-Module MSAL.PS
Import-Module MSAL.PS

Your final pipeline should look like the one below.

An additional issue you may face, could relate with the service connection authentication endpoint. The error indicates that the common endpoint cannot be used and the specific tenant-endpoint should be used instead.

##[error]AADSTS9001023: The grant type is not supported over the /common or /consumers endpoints. Please use the /organizations or tenant-specific endpoint.

Go and edit your service connection details

Endpoint URL:

https://login.microsoftonline.com/organizations

Be sure that your user has sufficient privileges and that prerequisites are met as documented from Microsoft.

LCS doesn’t support service-to-service authentication. Therefore, only regular user credentials (that is, a user name and password) can be used. Because the pipelines don’t run interactively, multifactor authentication must not be set up for the account that you use. We recommend that you set up a separate user account that has limited access and strong credentials that can regularly be rotated for security purposes.

Create an LCS connection in Azure Pipelines

https://docs.microsoft.com/en-us/dynamics365/fin-ops-core/dev-itpro/dev-tools/pipeline-lcs-connection

4 thoughts on “The specified module ‘MSAL.PS’ was not loaded because no valid module file was found in any module directory.

  1. Thanks a lot mate. this worked beautifully.
    However, i was stuck at this error for a while: ##[error]AADSTS9001023: The grant type is not supported over the /common or /consumers endpoints. Please use the /organizations or tenant-specific endpoint.
    But, i found from this link: https://stackoverflow.com/a/58067996 that i should change https://login.microsoftonline.com/organizations to https://login.microsoftonline.com/ and that worked.
    Thanks heaps, i think yours is the only article covering this issue.

    Can i also point an update, you can now add the “MSAL.PS install task” to the pipeline instead of adding the powershell script

    1. thanks for your update @Shashi

  2. Hi Geral,

    I faced the same error after I added Powershell
    “The grant type is not supported over the /common or /consumers endpoints. Please use the /organizations or tenant-specific endpoint.”

    I changed the endpoint to the following, but none works:
    https://login.microsoftonline.com/common
    https://login.microsoftonline.com/organizations
    https://login.microsoftonline.com/
    https://lcsapi.lcs.dynamics.com

    Can you advice? Thanks in advance.

    1. Unfortunately its been some time since I used LCS and maybe changes have been made since then. As I do not have a working environment right now, I would suggest @Shashi proposal, but you mentioned that you already tried. Maybe others faced the same issue on Microsoft forums, so I would suggest searching there also. https://powerusers.microsoft.com/t5/Microsoft-Power-Automate/ct-p/MPACommunity

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.