Using #requires directive with Devolutions.PowerShell module

Using #requires directive with Devolutions.PowerShell module

avatar

I usually add to script files directive to load required modules. For RDM module:

#Requires -Modules Devolutions.PowerShell

But from some time, it does not work any more. The script states that module is not loaded. Probably because the abovementioned module loads module with another name instead:

PS ❯ get-module Devolutions.PowerShell* -list

    Directory: C:\Program Files\PowerShell\Modules

ModuleType Version    PreRelease Name                                PSEdition ExportedCommands
---------- -------    ---------- ----                                --------- ----------------
Binary     2023.1.0.8            Devolutions.PowerShell              Core      {Add-RDMRoleRepositoryAccess, Add-RDMRoleToUser, Add-RDMSession…
Binary     2023.1.0.6            Devolutions.PowerShell              Core      {Add-RDMRoleRepositoryAccess, Add-RDMRoleToUser, Add-RDMSession…

PS ❯ get-module Devolutions.PowerShell*

ModuleType Version    PreRelease Name                                ExportedCommands
---------- -------    ---------- ----                                ----------------
Binary     2023.2.0.1            Devolutions.PowerShell.Extension    {Add-HubGroupUser, Add-RDMPrivateSessionAttachment, Add-RDMRoleRepository…


This second (loaded to memory) module is not visible for PowerShell, so I can't add #Requires directive into script for this module.

Is this change documented anywhere? Since which version this change occurred? Can it be changed back? Or how I am supposed to ensure that correct module is loaded before script starts work?

Meelis

All Comments (3)

avatar

Hello Meelis,

It's probably because of the multiple installed versions you have on you machine.

Did you get module version 2023.2.0.1 version to test it? It hasn't been officially released yet.

And for version 2023.1.0.6, you can remove it using the Uninstall-Module cmdlet so it won't affect your script anymore.

Does it work on a machine where only the latest official version 2023.1.0.8 is installed?

Best regards,

Érica Poirier

avatar

I removed module version 2023.1.0.6 and after that the problem resolved. The correct module is loaded and #Requires directive works again.

PowerShell usually loads always the latest version of installed modules. Does the Devolutions.PowerShell module changes the default loading sequence?

I see, that abovementioned module has nested module (named Devolutions.PowerShell.Extension) defined that actually loads the same .dll file. Is it possible that this confused PowerShell to think that the .extension module is right one to load?

avatar

Hello,

Thank you for your feedback and glad that removing version 2023.1.0.6 solved the issue.

I have asked our engineering team about your question regarding the nested module and we will keep you posted.

Thank you for your patience.

Best regards,

Érica Poirier