0

When creating a module manifest with the following

$settings = @{
    Path = $(Join-Path -Path  $PSScriptRoot -ChildPath "module.psd1")
    Author = "Author"
    CompanyName = "Company"
    ModuleVersion = "0.0.0"
    Guid = $(New-Guid)
    PowerShellVersion = "5.1.0"
    FunctionsToExport = "*"
    NestedModules = $(ls *.psm1)
    VariablesToExport = "G_*"
}
New-ModuleManifest @settings

and trying to import it with

using module "../modules/Common/module.psd1"

Write-Host "Hello World!"

with powershell 5.1 i see

.\test_using_modules.ps1 : The specified module was not loaded because no
valid module file was found in any module directory.

however it works just fine with powershell 7.1. With powershell 5.1 it works if cd-ing into module dir and importing that module in there.

From docs on modules, I do not see a big difference wrt module manifests. Any suggestions on what I can be doing wrong?

Viktor Khristenko
  • 863
  • 1
  • 5
  • 17
  • I believe the problem is that in Powershell 5 (which is Windows Powershell) the linux style path is treated differently than Windows-style path. At least changing the `using module ./...` with `using module .\...` makes things work as expected – Viktor Khristenko Feb 13 '23 at 12:30

0 Answers0