I must be missing something basic here, but i'm new to powershell...
I wrote a function and saved it in a file called "UserSelectionList.psm1", the function is stubbed out like this:
function Global:UserSelectionList([String[]] $UserOptions)
{
...
}
i then try to call it with this script:
Import-module "l:\support downstream\solarc\cngl\powershell scripts\userselectionlist.psm1"
$Options = "a","b","c"
cls
$result = UserSelectionList $Options
echo $result
The resulting error is:
The term 'UserSelectionList' 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 line:5 char:28
+ $result = UserSelectionList <<<< $Options
+ CategoryInfo : ObjectNotFound: (UserSelectionList:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
I'm planning to have more than one function in a module, but this is where I'm at.
thanks in advance
I've encountered the same problem. Steps to reproduce:
Import-Module statementThe error went away after I added the -Force argument to Import-Module. The -Force argument can be removed once the function in the imported module is able to be called.
Note that latkin has alluded to this solution in his comment to the question. I'm hoping this will make it more visible.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With