Connect-exchangeonline will not load due to unsigned files in temp directory

absoblogginlutely 136 Reputation points
2021-02-23T20:32:22.543+00:00

Powershell 5.1, Exchangeonlinemanagement installed from psgallery with install-module exchangeonlinemanagement.
Module v 2.0.4 installed to C:\Program Files\WindowsPowerShell\Modules

After running "connect-exchangeonline", successfully authenticating with 2FA, the session is generated and then the screen errors with

Import-Module : Errors occurred while loading the format data file:
C:\temp\temp\tmp_vexfwmg2.gol\tmp_vexfwmg2.gol.format.ps1xml, , C:\temp\temp\tmp_vexfwmg2.gol\tmp_vexfwmg2.gol.format.ps1xml: The file was skipped because of the following validation exception: File C:\temp\temp\tmp_vexfwmg2.gol\tmp_vexfwmg2.gol.format.ps1xml cannot be loaded. The file C:\temp\temp\tmp_vexfwmg2.gol\tmp_vexfwmg2.gol.format.ps1xml is not digitally signed. You cannot run this script on the current system. For more information about running scripts and setting execution policy, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170.. At line:3 char:17

  • ... Import-Module -Name $name -Alias * -Function * -Prefix $p ...
  • ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  • CategoryInfo : InvalidOperation: (:) [Import-Module], RuntimeException
  • FullyQualifiedErrorId : FormatXmlUpdateException,Microsoft.PowerShell.Commands.ImportModuleCommand

get-executionpolicy shows remotesigned (as expected).
Set-executionpolicy unrestricted allows the install to continue and connect to exchange but obviously that's a bad idea.

Why is the module generating local files in my temp directory (that change everytime so I can't unblock them) ?

Microsoft Exchange Online Management
Microsoft Exchange Online Management
Microsoft Exchange Online: A Microsoft email and calendaring hosted service.Management: The act or process of organizing, handling, directing or controlling something.
3,389 questions
0 comments No comments
{count} votes

Accepted answer
  1. absoblogginlutely 136 Reputation points
    2021-07-22T17:40:50.817+00:00

    Thanks for the reply KyleXu.
    For some reason I did not get notification on this.
    However I found that changing my temp directory setting from c:\temp\temp to c:\andy\temp the issue went away. I didn't have to do anything else apart from change the temp directory.
    I suspect a weird permission on the temp directory but it looked ok.

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. KyleXu-MSFT 25,866 Reputation points
    2021-02-24T02:08:16.463+00:00

    @absoblogginlutely

    Here is the configuration on my computer:
    71345-qa-kyle-09-59-00.png

    I could install ExchangeOnlineManagement module and connect successfully:
    71361-qa-kyle-09-57-36.png

    I would suggest you uninstall and install this module again. After uninstalling this module, you need to close and open a new PowerShell windows.

    If you still cannot use this module successfully, I think there may exist some issue with your PowerShell 5.1, you can try to install PS 7.0 on your computer and install this module in it.

    If you cannot connect to Exchange online with PS7.0, you could post this issue in PowerShell github, that project mainly collect and solve issue with PowerShell to improve the experience of using PowerShell.


    If the response is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.