Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8694459
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T00:47:41+00:00 2026-06-13T00:47:41+00:00

I have a simple module called MyModule.psm1 defined as function Show-Text($p) { Write-Host $p

  • 0

I have a simple module called MyModule.psm1 defined as

function Show-Text($p)
{
    Write-Host $p
}

Export-ModuleMember Show-Text

Module is saved here – (All works fine, the normal way via ISE or direct Powershell command line)

C:\Windows\SysWOW64\WindowsPowerShell\v1.0\Modules\MyModule (because 64-bit OS)

Now, I have a script called Test.ps1 like this

Show-Text "Hello World"

NB: I do not want to do Import-Module MyModule in the ps1 file

I am running following command from a cmd.exe window

C:\>Powershell -Command "& {Import-Module MyModule}" -File "C:\temp\Test.ps1"

I get the following error

Import-Module : The specified module ‘MyModule’ was not loaded because
no valid module file was found in any module directory. At line:1
char:17
+ & {Import-Module <<<< MyModule} -File Show.ps1
+ CategoryInfo : ResourceUnavailable: (MyModule:String) [Import-M odule], FileNotFoundException
+ FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Comm
ands.ImportModuleCommand

Can somebody help me how to execute exactly what I have stated above via cmd.exe ONLY without hard-coding or specifying the full Module Path please ?

Something on the similar lines we do for loading SystemModules – powershell.exe -ImportSystemModules

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T00:47:42+00:00Added an answer on June 13, 2026 at 12:47 am

    Are you running a 32-bit cmd.exe? If so then the Import-Module should work. If you are running a 64-bit cmd.exe, that will launch a 64-bit PowerShell.exe unless you fully qualify the path to the 32-bit version of PowerShell.exe (c:\windows\syswow64\windowspowershell\v1.0\powershell.exe).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following simple type: module Structures type Point2D<'T> (x : 'T, y
I have created a simple Python module and want to distribute it with pip.
I have a simple Python script that uses the socket module to send a
Need assistance with the pexpect module I have written a simple code which would
I have the following code in my simple ubercart payment gateway module to redirect
I have a module in my Drupal 7 application called Feedback. It includes a
I am using a popular module called Computed Field in Drupal. I have used
I have a very simple Win32 application that uses CAtlExeModuleT. The module simply creates
I have tested optcomplete working with the optparse module. Its example is a simple
I'm in Visual Studio 2003. I have a function in a very common module

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.