0

I have a strange problem I have created a module and placed it in the “C:\Windows\System32\WindowsPowerShell\v1.0\Modules” directory .

I can open powershell and import my module fine but it does not work when I do the following.

I have batch file that calls the powershell script using the following command START /min /wait powershell "C:\test.ps1" "%1"

The script starts but it is unable to import module.

I placed this command “Get-Module -ListAvailable | Out-File c:\module.txt” in the test.ps1.

When I review the module.txt file I see it does not list my module there.

It seems that for some reason when I call the script this way it can’t access the module

1 Answer 1

1

A module has to be either a .psm1 file or a .psd1 manifest file (or a dll). A .ps1 doesn't qualify as a module, it is "just" a script.

Sign up to request clarification or add additional context in comments.

8 Comments

I have one file called test.psm1 in a directory called test
Is this a 64-bit system? If so, can you check to see if the PowerShell instance created by the batch file is a 64-bit or a 32-bit PowerShell? Stick in [intptr]::size > c:\test.log in your test.ps1 file.
It is a 64bit system and the instance is 32 bit , does that make a difference , do I need to change any thing ?
any idea why cmd is launching the 32 bit version? and how i could make it launch a 64 bit version with the bat file like i have it?
Are you running the 64-bit cmd.exe or the 32-bit cmd.exe? If you're running the 64-bit cmd.exe then a start of "powershell" should launch the 64-bit version of PowerShell. The other option is to put your module also in C:\Windows\SysWow64\WindowsPowerShell\v1.0\Modules.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.