Configuration guides for IT Administrators

Error while importing PSSession on Microsoft365

Error while importing PSSession on Microsoft365

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

Leave a Reply

Your email address will not be published. Required fields are marked *

Lucas Brey

I’m Lucas Brey, a travel blogger sharing practical guides, hidden gems, and honest tips from the road. Follow along for smart itineraries, great food finds, and stories worth bookmarking.

Tags