Welcome › Forums › General PowerShell Q&A › Module Functions – Prompted for nested mandatory arguments on import?
- This topic has 2 replies, 3 voices, and was last updated 1 week, 5 days ago by
Participant.
-
AuthorPosts
-
-
January 12, 2021 at 10:42 pm #285568
Heyo!
I’m currently using the Public/Private folder paradigm in my modules. So far, so good. However, I’ve got a module with two functions, the main ‘public’ function has mandatory params and it calls a sibling function (also with mandatory params). When I import the module, the secondary module prompts me for the params, which I don’t want.
If I remove the mandatory tags on the second function’s params, it imports OK…
I don’t think I’ve seen this before, I’m sure it has to be a scoping thing. Do I have to hide the secondary function in Private? I’d like to expose it as a public function too.
-
January 13, 2021 at 8:21 am #285613
There is no such contract and no harm too. You can make it public if you see it relevant. When calling any function which has mandatory parameters, those mandatory inputs has to be passed.
-
January 13, 2021 at 3:43 pm #285670
Are you sure you’re not calling it somewhere accidentally. It shouldn’t be calling functions to tell you something is mandatory, so in the PS1 import file it would be like this:
PowerShell1234function Test-It {}Test-ItWhen I was testing I didn’t remove the call and it was showing behavior like that.
-
-
AuthorPosts
- You must be logged in to reply to this topic.