PowerShell for Windows Admins

May 5 2013   4:30PM GMT

Scripting games–using parameters

Richard Siddaway Richard Siddaway Profile: Richard Siddaway

I am seeing an incredible number of scripts that have this sort of coding round parameters

# Input from the user
[ValidateScript({Test-Path $_ })]
[String]$SourcePath = ‘C:\Application\Log’,

[ValidateScript({Test-Path $_ })]
[String]$ArchivePath = ‘\\NASServer\Archives’,

[Int]$Days = 90

Why do you need to state that Mandatory=$false or that ValueFromPipeline=$False. The DEFAULT values are false. You only need to use them if you are setting them to TRUE.

Its a waste of coding time and processing time when you run the script.

I remember blogging about this last year.

Please stop doing it so I don’t have to blog about it next year

 Comment on this Post

There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when other members comment.

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

Share this item with your network: