Menu Title

Error while importing PSSession on Microsoft365

PowerShell_ExchangeOnline_RemoteSigned

While executing PowerShell command "Import-PSSession $Session" on Microsoft 365 account, an error is thrown as "Files cannot be loaded because running scripts is disabled on this system". This happens because you have not properly configured the PowerShell execution policy otherwise your admin has forced restrictions via GPO.

Import-PSSession : Files cannot be loaded because running scripts is disabled on this system. Provide a valid
certificate with which to sign the files.
At line:1 char:1
+ Import-PSSession $Session
+ ~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Import-PSSession], PSInvalidOperationException
+ FullyQualifiedErrorId : InvalidOperation,Microsoft.PowerShell.Commands.ImportPSSessionCommand

In order to fix this Import-PSSession error, run following command to permit scripts execution

  1. Open PowerShell with administrator privilege
  2. Execute "Set-ExecutionPolicy RemoteSigned". Press Y when asked. Then Import-PSSession should execute perfectly.

PowerShell_ExchangeOnline_RemoteSigned

Related Post