Can’t run Import-Module MicrosoftTeams because running scripts is disabled on this system.

Situation: When running Import-Module MicrosoftTeams PowerShell command, you may receive this error:

Import-Module : File C:\Program Files\WindowsPowerShell\Modules\MicrosoftTeams\5.8.0\MicrosoftTeams.psm1 cannot be
loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at
https:/go.microsoft.com/fwlink/?LinkID=135170.
At line:1 char:1
+ Import-Module MicrosoftTeams
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : SecurityError: (:) [Import-Module], PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess,Microsoft.PowerShell.Commands.ImportModuleCommand

Resolution:

Your PowerShell Execution Policy might be preventing Import-Module from running successfully. Try running:

Set-ExecutionPolicy -ExecutionPolicy AllSigned -Scope Process

This will allow all signed scripts to run in the current PowerShell process. When you close the PowerShell session, you will revert to your previous Execution Policy.

If the module is still not successfully importing, you might try:

 Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope Process

Be cautious about this setting, since it will allow any unsigned scripts to run, including potentially malicious code. Ensure that you trust the script/modules you’re installing if you choose ExecutionPolicy Bypass.

 

Published by

Bob Lin

Bob Lin, Chicagotech-MVP, MCSE & CNE Data recovery, Windows OS Recovery, Networking, and Computer Troubleshooting on http://www.ChicagoTech.net How to Install and Configure Windows, VMware, Virtualization and Cisco on http://www.HowToNetworking.com

Leave a Reply