Solved

powershell parameter

Posted on 2014-10-27
2
125 Views
Last Modified: 2014-11-10
Hi Guys,

I have found script online and it contains this code:

Param (
        [parameter(Position=0,ValueFromPipeline=$True,ValueFromPipelineByPropertyName=$True)]
        [Alias('FullName')]
        [string[]]$Path = $PWD,
        [parameter(ParameterSetName='Filter')]
        [string[]]$Filter = '*.*',    
        [parameter(ParameterSetName='Exclude')]
        [string[]]$ExcludeFile,              
        [parameter()]
        [int]$MaxAge,
        [parameter()]
        [int]$MinAge
    )

Open in new window


I really need to understand what this is saying and I am trying to advance in powershell.

to begin with what does this line mean:

[parameter(Position=0,ValueFromPipeline=$True,ValueFromPipelineByPropertyName=$True)]

please can someone give an explantion with examples.

thank you in advance.

Regards,
Kelly
0
Comment
Question by:Kay
2 Comments
 
LVL 39

Accepted Solution

by:
footech earned 500 total points
ID: 40407022
You should check out the built-in help for about_functions_advanced_parameters.

The code defines restrictions/properties for input parameters of the script or function.
Just like when you look at the full help for a cmdlet, it will tell you about the different parameters the cmdlet supports.  For example:
   -Path <String[]>
        Specifies the path to an item. Get-Content gets the content of the item. Wildcards are permitted. The parameter name ("Path" or "FilePath") is optional.

        Required?                    true
        Position?                    1
        Default value                
        Accept pipeline input?       true (ByPropertyName)
        Accept wildcard characters?  true

I could go on about the different arguments that each parameter has defined, but the help already covers that.  So try reading that and then if you have further questions I can try to clarify.
0
 
LVL 12

Expert Comment

by:Vaseem Mohammed
ID: 40407854
0

Featured Post

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Create and license users in Office 365 in bulk based on a CSV file. A step-by-step guide with PowerShell script examples.
A procedure for exporting installed hotfix details of remote computers using powershell
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now