//
stai leggendo...
domanda

Scripting games–using parameters

Richard Siddaway's Blog

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

 

# Input from the user
    [Parameter(Mandatory=$false,
               ValueFromPipeline=$False,
               Position=0)]
    [ValidateScript({Test-Path $_ })]
    [String]$SourcePath = ‘C:\Application\Log’,
 
 
    [Parameter(Mandatory=$false,
               ValueFromPipeline=$False,
               Position=1)]
    [ValidateScript({Test-Path $_ })]
    [String]$ArchivePath = ‘\\NASServer\Archives’,
 
 
    [Parameter(Mandatory=$false,
               ValueFromPipeline=$False,
               Position=2)]
    [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

View original post

Discussione

Non c'è ancora nessun commento.

Lascia un commento