I should follow this question, but I can't get it to work.
(For testing) I have a powershell module with two scripts: variables.ps1 and function.ps1 and the manifest mymodule.psd1 (these files are in the same directory)
This is the contents of the .ps1 variables:
$a = 1;
$b = 2;
This is the contents of the .ps1 function
. .\variables.ps1
function myfunction
{
write-host $a
write-host $b
}
When importing a module and calling myfunction. This is the result:
C:\> Import-Module .\mymodule.psd1
C:\> myfunction
. : The term '.\variables.ps1' is not recognized as the name of a cmdlet, function, script file, or operable
program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At C:\Users\Jake\mymodule\function.ps.ps1:8 char:4
+ . .\variables.ps1
+ ~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (.\variables.ps1:String) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : CommandNotFoundException
Why is this not working?
source
share