Solved

powershell parameter

Posted on 2014-10-27
2
136 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
 
LVL 12

Expert Comment

by:Vaseem Mohammed
ID: 40407854
0

Featured Post

Does Powershell have you tied up in knots?

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

I thought I'd write this up for anyone who has a request to create an anonymous whistle-blower-type submission form created using SharePoint 2010 (this would probably work the same for 2013). It's not 100% fool-proof but it's as close as you can get…
A brief introduction to what I consider to be the best editor for PowerShell.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
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…

696 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