Powershell Tutorial Online


Script Parameters / Arguments (for scripts, functions and script blocks) To pass arguments to a script or cmdlet type them separated by spaces:

You just have to know how to declare your parameters.

Scenario 1:


Scenario 2: I could use the parameters like this:

Get-Something –computerName SERVER1 –filePath C:\Whatever

You can do the parameter validation using PowerShell.

ValidateNotNull only checks to see if the value being passed to the parameter is a null value. Empty string is still valid.
ValidateNotNullorEmpty This also checks to see if the value being passed is a null value and if it is an empty string or collection

    Function TestingMethod {
        [ValidateNotNull()] #No value
        $Item )
    Process {