January 1, 2012 at 12:00 am #5932MemberPoints: 0Rank: Member
by NMayberry at 2012-10-16 09:38:56
I am creating a script to give to people and was wondering if there is a way to create a hidden parameter that does not show up in help/syntax. Basically thinking that of including a "-Testing" parameter where I can, for example, specify my own email address instead of broadcast email. That way I can test to my heart's content, but not worry about accidently not commenting out something or having to change other things when I go to release it. It might be a bad idea for the testing process as I can see me forgetting to include the "-Testing" when running my script, but I thought it was an interesting question.
by willsteele at 2012-10-16 12:19:23
The first thing that comes to mind is using the Verbose pipeline. Technically, as far as I know, there is no way to suppress a given parameter from appearing with the help. If you add it as a parameter it will show up in help. One idea is to possibly consider doing a dynamic parameter. Even then, you will still have to have something that triggers when the new dynamic parameter appears, but, this could be something to look into.
by mjolinor at 2012-10-17 07:43:09
I think Microsoft invented the phrase "For internal use only." for just such an occasion.....
by poshoholic at 2012-10-18 08:03:30
I think a better approach would be to put any parameters you want to change during testing in a module as script variables, which are private by default and not visible external to the module, and then in your test environment when you load the module you could modify the values of those internal private variables directly. This would allow you to change the behavior locally without changing any part of the logic in your module so that you don't have to worry about forgetting to clean up afterwards. It's also a good approach to take because if someone else is using your script and having issues, you can provide them with steps that allow them to change the behavior in their environment as well, for testing/troubleshooting purposes.
by megamorf at 2012-10-18 16:57:21
I'm not sure if I understand your issue correctly. Do you need your email address just for testing purposes oder for contact? For the latter you could simply do:
What does the script do?
What does the script do more specifically?
Contact me at: email@example.com
Or you specify your "test email address" as follows so that users have to specify another address for production use
[string]$EMail = "firstname.lastname@example.org"
by nohandle at 2012-10-19 03:59:17
I think a better approach would be to put any parameters you want to change during testing in a module as script variables,
I am so glad the same solution occurred to me too. 🙂
The topic ‘Creating a hidden parameter’ is closed to new replies.