Going along with my scripting project of the week, I'm trying to write a script that will query each network computer's WMI and report back their respective results. I'm trying to make my scripts at this point to be universal where they follow the convention of internal help files, parameter sets, and all that jazz. Of course, the first one I truly attempt it on I'm running into an issue.
I want to set it up where the end user chooses how the output will be using parameters. They could either choose on-screen, a text file, print it, HTML, or send it as an attachment. I've looked at parameter sets (thanks to Martin's blog!), but those I don't think would be right for this part. I would like to plan on using one for the email so that a file type is mandatory for the attachment though.
This is my PARAM section now:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | Param(#Input file or computer name[Parameter(Mandatory=$False)][Alias("target","computer")][string]$TargetPath=[Environment]::MachineName,#Output file[Parameter(Mandatory=$False)][Alias("out","report")][string]$OutputPath=[Environment]::GetFolderPath("Desktop"),#Output type[Parameter(Mandatory=$false)][Alias("type")][string]$OutputType="screen") |
For the $OutputType, how do I need to change it so it's cleaner/"legal"? The last time I did something like this I ended up with an ugly series of IF statements. In my head it looks like the old VBS way where each possible switch option fired off a function, and each function dealt with the output formatting.