How to install PowerShell modules

Should installing PowerShell modules work? Or do they need to be specifically packaged for Nix?

I tried installing one and it promptly crashed:

$ nix-shell --packages powershell --command pwsh
> Install-Module –Name ExchangeOnlineManagement
> Connect-ExchangeOnline
[authentication in web browser]
/nix/store/1p4aw8vchkfq6k514z1iglwbas2v810l-powershell-7.2.0/share/powershell/pwsh: symbol lookup error: /nix/store/1p4aw8vchkfq6k514z1iglwbas2v810l-powershell-7.2.0/share/powershell/libmi.so: undefined symbol: SSL_library_init

Where would you begin troubleshooting this?

1 Like

Maybe here?

No crash here when I do add that module, and connect, NixOS 21.11

This is […] for managing keys and certificates […]. It contains commands to create and manage private keys, certificate requests, and certificates.

or here:

the option:

Connect-ExchangeOnline -EnableErrorReporting ...?

Oh and logging too:

Connect-ExchangeOnline -EnableErrorReporting -LogDirectoryPath <Path to store log file> -LogLevel All

PowerShell 7.2.0
Copyright (c) Microsoft Corporation.

https://aka.ms/powershell
Type 'help' to get help.

PS /home/xxx> Install-Module –Name ExchangeOnlineManagement

Untrusted repository
You are installing the modules from an untrusted repository. If you trust this repository, change its InstallationPolicy value by running the Set-PSRepository cmdlet. Are you sure you want 
to install the modules from 'PSGallery'?
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "N"): Y
PS /home/xxx> Install-Module -Name OpenSSL                                                                             

Untrusted repository
You are installing the modules from an untrusted repository. If you trust this repository, change its InstallationPolicy value by running the Set-PSRepository cmdlet. Are you sure you want 
to install the modules from 'PSGallery'?
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "N"): Y
PS /home/xxx> Connect-ExchangeOnline                                                                                   

----------------------------------------------------------------------------
The module allows access to all existing remote PowerShell (V1) cmdlets in addition to the 9 new, faster, and more reliable cmdlets.

|--------------------------------------------------------------------------|
|    Old Cmdlets                    |    New/Reliable/Faster Cmdlets       |
|--------------------------------------------------------------------------|
|    Get-CASMailbox                 |    Get-EXOCASMailbox                 |
|    Get-Mailbox                    |    Get-EXOMailbox                    |
|    Get-MailboxFolderPermission    |    Get-EXOMailboxFolderPermission    |
|    Get-MailboxFolderStatistics    |    Get-EXOMailboxFolderStatistics    |
|    Get-MailboxPermission          |    Get-EXOMailboxPermission          |
|    Get-MailboxStatistics          |    Get-EXOMailboxStatistics          |
|    Get-MobileDeviceStatistics     |    Get-EXOMobileDeviceStatistics     |
|    Get-Recipient                  |    Get-EXORecipient                  |
|    Get-RecipientPermission        |    Get-EXORecipientPermission        |
|--------------------------------------------------------------------------|

To get additional information, run: Get-Help Connect-ExchangeOnline or check https://aka.ms/exops-docs

Send your product improvement suggestions and feedback to exocmdletpreview@service.microsoft.com. For issues related to the module, contact Microsoft support. Don't use the feedback alias for problems or support issues.
----------------------------------------------------------------------------

And then it connects to web page for logging in, no crash

Thanks, I think I wasn’t clear above; the crash happens immediately after authenticating in the browser.

OK, I had no account to log in, only I was notified that my user account (outlook.com account) was unknown

So do the extra options help in debugging?

maybe it has something to do with this: ( searching for: libmi.so: undefined symbol: SSL_library_init )

Ah that looks related, thanks. So it wants an older version of OpenSSL. I think the next step is to figure out how to make it use nixos.openssl_1_0_2.

The extra application logging (and I suspect telemetry?) options didn’t have any noticeable effect.

yes, maybe that does the trick!

in nix-shell command-line add nixos.openssl_1_0_2 so it will use that?

like: nix-shell --packages powershell --command pwsh -p openssl_1_0_2 ?

I see it needs export NIXPKGS_ALLOW_INSECURE=1, but it seems to compile…

I did try that, to no effect. I see now that the powershell packaging does some editing around OpenSSL though I don’t really follow it. It’s replacing 1.0 with 1.1?

Hmm, I take a break for an expert opinion, good luck!

1 Like