justinf
justinf

Reputation: 1298

Unable to import a powershell module from a script

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

Upvotes: 0

Views: 2585

Answers (1)

Keith Hill
Keith Hill

Reputation: 201602

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.

Upvotes: 1

Related Questions