Could not load file or assembly Microsoft.Identity.Client

In some cases, you may receive the following error when running Easy365Manager (clicking on the Office 365 tab or Mailbox tab):

This error message can appear if PowerShell has been locked down with a PSLockDownPolicy.
If PSLockdownPolicy has set the ExecutionContext SessionState LanguageMode to Constrained Language Mode (CLM) then Microsoft Graph PowerShell will not function.

You can verify if this is the case by executing the following command:

PS C:\> $ExecutionContext.SessionState.LanguageMode

When Constrained Language Mode is enabled, the list of modules available to PowerShell scripting is limited.

Most importantly, in terms of Easy365Manager, you won’t be able to run MS Graph PowerShell scripts.

How to Fix It

Constrained Language Mode is usually set systemwide using the following registry key:

((HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\__PSLockDownPolicy))

To fix this issue, you need to remove the key or set it to 8.

The change will only affect new PowerShell instances, so you’ll need to open a new PowerShell prompt to verify the settings:

PS C:\> $ExecutionContext.SessionState.LanguageMode

You can also check the variable directly using the following command:

PS C:\> $env:__PSLockDownPolicy