The Import-PSSession and Export-PSSession cmdlets create modules that contains unsigned script files and formatting files.

To import the modules that are created by these cmdlets, either by using Import-PSSession or Import-Module, the execution policy in the current session cannot be Restricted or AllSigned. For information about Windows PowerShell execution policies, see about_Execution_Policies.

If you try to import a module on a system where the execution policy does not permit unsigned scripts, Windows PowerShell generates the following error message.

  Copy Code
ERROR: Import-Module: File <filename> cannot be loaded because the execution of scripts is disabled on this system.

To import a module without changing the execution policy

  • Use the Scope parameter of the Set-ExecutionPolicy cmdlet to set a less restrictive execution policy for a single Windows PowerShell process.

    For example, the following command starts a process with the RemoteSigned execution policy. The execution policy change affects only the current process and does not change the Windows PowerShell execution policy that is set in the registry.

To start a session with a specified execution policy

  1. Use the ExecutionPolicy parameter of PowerShell.exe to start a single session with a less restrictive execution policy.

    For example, the following command starts a session with the RemoteSigned execution policy.

      Copy Code
    powershell.exe -executionpolicy RemoteSigned

See Also