Solved

powershell parameter

Posted on 2014-10-27
2
146 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 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

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Synchronize a new Active Directory domain with an existing Office 365 tenant
This article will help you understand what HashTables are and how to use them in PowerShell.
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…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…

707 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