DirSync Troubleshooting: Fixing execution policy error when importing module in PowerShell

Issue

If your Windows PowerShell execution policy is set to ‘Restricted’, then when importing the DirSync PowerShell module you might run into the following error:

Sync\dirsync\ImportModules.ps1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at http://go.microsoft.com/fwlink/?LinkID=135170.

At line:1 char:1

+ import-module dirsync

+ ~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : SecurityError: (:) [Import-Module], PSSecurityException

    + FullyQualifiedErrorId : UnauthorizedAccess,Microsoft.PowerShell.Commands.ImportModuleCommand

Solution

To fix the issue, please run the following command and import the DirSync module again.

 Set-ExecutionPolicy RemoteSigned -Scope process

 Execution Policy Change

The execution policy helps protect you from scripts that you do not trust. Changing the execution policy might expose you to the security risks described in the about_Execution_Policies help topic at

http://go.microsoft.com/fwlink/?LinkID=135170.

Do you want to change the execution policy?

[Y] Yes  [N] No  [S] Suspend  [?] Help (default is "Y"): y