?
Solved

powershell parameter

Posted on 2014-10-27
2
Medium Priority
?
154 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 40

Accepted Solution

by:
footech earned 2000 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

Featured Post

Ransomware Attacks Keeping You Up at Night?

Will your organization be ransomware's next victim?  The good news is that these attacks are predicable and therefore preventable. Learn more about how you can  stop a ransomware attacks before encryption takes place with our Ransomware Prevention Kit!

Question has a verified solution.

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

The following article is intended as a guide to using PowerShell as a more versatile and reliable form of application detection in SCCM.
Previously, on our Nano Server Deployment series, we've created a new nano server image and deployed it on a physical server in part 2. Now we will go through configuration.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

765 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