by BustedFlush at 2013-02-09 10:21:48
In this article regarding Powershell parameters, Don Jones writes:by DonJ at 2013-02-09 12:45:06
(http://technet.microsoft.com/en-us/maga … 54301.aspx)
"You can tell Windows PowerShell to expect these parameters, collect them from the command line, and put their values into variables within your script or function. That makes dealing with input easy and efficient.
You just have to know how to declare your parameters. The simplest means of doing so is the param block:
And that’s just great, but I have a question; why did declare the variable types like that? ([string])
Is it necessary?
Does it provide any added functionality or prevent potential problems?
It isn’t necessary, but it (a) ensures I get a string - as opposed to a Service object or something else - in the parameter, and (b) helps document what the parameter expects for anyone running the command. PowerShell uses that to construct a basic default help display, for example.