Scripting games–using parameters

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 to blog about it next year

This entry was posted in Powershell, Scripting Games. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s