Milosz Krajewski
Milosz Krajewski

Reputation: 1210

"Import-Module MSMQ" fails on PowerShell @ Windows 11 Home/Pro

I had a script creating MSMQ queues on Windows 10 and everything worked fine. On Windows 11 however (Pro and Home, to be specific), it fails.

It started to fail by just not finding New-MsmqQueue:

The term 'New-MsmqQueue' is not recognized as the name of a cmdlet, function, script file, 
or operable program.

I tried to Import-Module MSMQ and it almost (almost, as we know, makes a huge difference) addressed a problem.

I say almost as Import-Module MSMQ also fails with:

The module manifest cannot contain both the 'ModuleToProcess' and 'RootModule' members. 
Change the module manifest file to remove one of these members at
'C:\Windows\system32\WindowsPowerShell\v1.0\Modules\MSMQ\MSMQ.psd1', 
and then try again.

I looked inside the mentioned file and yes, in fact, it contains both ModuleToProcess and RootModule but first of all I should not edit system file and secondly... I cannot edit them.

I created a copy of this module and "experimentally" modified it (by removing RootModule) and it seems to be working fine, but this is not a solution.

NOTE: I'm running this on "fresh" installation (Win11_22H2_EnglishInternational_x64v2.iso)

NOTE: I tried both (Windows) PowerShell 5 and the new (Core) PowerShell 7.

NOTE: MsMQ Windows Feature is fully installed (all boxes ticked)

Anyone seen this? Am I missing something?

EDIT: Windows 10 does not have this problem and does not have RootModule is .psd1 file. As RootModule references MSMQ.psm1 I checked it and it seems be dealing with Intel/ARM differences, and I assume it was not a case in Windows 10.

Upvotes: 3

Views: 535

Answers (1)

r4v3n6
r4v3n6

Reputation: 46

This is a known issue in Windows 11, which will be addressed in update.

As a workaround meanwhile:

Backup and open MSMQ.psd1 (C:\Windows\system32\WindowsPowerShell\v1.0\Modules\MSMQ) as admin.

Change ModuleToProcess to NestedModules in MSMQ.psd1

Save

Import-Module MSMQ

Upvotes: 0

Related Questions