Skip to content

Using module statement doesn't work with ScriptsToProcess #2962

Open

Description

@juneb

Steps to reproduce

  1. Define PowerShell classes in a script module.
  2. Write a test script, Write-Hello.ps1, that returns "Hello World"
  3. At the command line, use the Using module statement to import the script module.

Expected behavior

The classes in the script module are imported into and available in the caller's session.

Actual behavior

The classes in the script module are NOT imported into and available in the caller's session.
If you comment out the ScriptsToProcess key, the classes are correctly imported into the session.

Environment data

PS C:\Program Files\PowerShell\6.0.0.14> $PSVersionTable

Name Value


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

Activity

  1. added
    WG-Engine
    on Feb 15, 2017
  2. mklement0 commented on Sep 2, 2021

    @mklement0
    Contributor

    Just ran into this (in 7.2.0-preview.9).

    Curiously, executing the using module statement again then makes the classes visible to the caller.

  3. microsoft-github-policy-service commented on Nov 16, 2023

    @microsoft-github-policy-service
    Contributor

    This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.

  4. microsoft-github-policy-service commented on Nov 16, 2023

    @microsoft-github-policy-service
    Contributor

    This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.

  5. added
    Resolution-No Activity
    on Nov 16, 2023
  6. microsoft-github-policy-service commented on Nov 16, 2023

    @microsoft-github-policy-service
    Contributor

    This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.

  7. microsoft-github-policy-service commented on Nov 23, 2023

    @microsoft-github-policy-service
    Contributor

    This issue has been marked as "No Activity" as there has been no activity for 6 months. It has been closed for housekeeping purposes.

  8. added
    KeepOpen
    and removed
    Resolution-No Activity
    on Nov 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    KeepOpenWG-Engine

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions