Skip to content

Using module behavior on nested modules is inconsistent #2964

@juneb

Description

@juneb

When you use the Using module statement in a script, classes defined in nested modules are imported and available for use in the script. But, the same code run at the command line fails to import the classes from nested modules.

I didn't expect the classes in nested modules to be exported at all, but the same code should work the same way in a script and at the command line.

Steps to reproduce

  1. Define some PowerShell classes in a .psm1 file
  2. In the module manifest, set ModuleToProcess to '' and NestedModules to the name of the .psm1.
  3. In a script, use the Using module statement to import the module and instantiate one of the classes in the nested module.
  4. At the command line, run the commands in the script one-by-one.

Expected behavior

The script and command-line experiences are the same. Either they both work or they both fail.

Actual behavior

In the script, the Using module statement imports the classes in a nested module. Using the classes succeeds. At the command line, the Using module statement does not import the classes in a nested module. Using the classes fails.

Environment data

Name                           Value
----                           -----
PSRemotingProtocolVersion      2.3
PSVersion                      6.0.0-alpha
GitCommitId                    v6.0.0-alpha.14
BuildVersion                   3.0.0.0
CLRVersion
SerializationVersion           1.1.0.1
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
PSEdition                      Core
WSManStackVersion              3.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Resolution-No ActivityIssue has had no activity for 6 months or moreWG-Enginecore PowerShell engine, interpreter, and runtime

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions