Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3605526
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T21:08:05+00:00 2026-05-18T21:08:05+00:00

I’d like to disable PowerShell’s common parameters for one of my functions. I’ve been

  • 0

I’d like to disable PowerShell’s “common parameters” for one of my functions. I’ve been working on a set of extensions to p4.exe (the Perforce command line utility) by writing a function something like this:

function p4(
    [parameter(valuefromremainingarguments=1)]
    [string[]]$cmdline)
{
    # ...do some fun stuff with $cmdline...
    p4.exe $cmdline  # for illustration only - actual implementation uses .net objects
}

The point is to be able to use p4 just like I normally do on the command line, except sometimes magically some parameters will get reprocessed (to add new commands or call different tools or whatever) and it will always feel as if I’m just using the normal p4 command line.

This is working pretty well, until I start using a parameter like ‘-o’.

p4 -p 1666 user -o scobi

In this case, I get an error from PowerShell:

p4 : Parameter cannot be processed because the parameter name 'o' is ambiguous. Possible matches include: -OutVariable -OutBuffer.

The only way I’ve found around it is to quote my parameters:

p4 -p 1666 user '-o' scobi
p4 '-p 1666 user -o scobi'

Yucky, and gets in the way of my goal of having this function be a transparent superset of p4.exe.

Is there a magic attribute I can attach to my function to make it tell the shell “I don’t support common parameters”? Or are there any other ways around this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T21:08:05+00:00Added an answer on May 18, 2026 at 9:08 pm

    Do not use advanced function at all, use a normal function with no parameters. Inside the function use $args to refer to the arguments.

    function p4()
    {
        $args
    }
    
    p4 -p 1666 user -o scobi
    

    Output:

    -p
    1666
    user
    -o
    scobi
    

    UPDATE

    In fact the function still can use its own parameters, for example:

    function p4($myparam)
    {
        "param $myparam"
        $args
    }
    
    p4 -p 1666 user -o scobi -myparam value
    

    Output:

    param value
    -p
    1666
    user
    -o
    scobi
    

    Caution: parameter names should not conflict with other potential arguments. For example, this does not work:

    function p4($param)
    {
        "param $param"
        $args
    }
    
    p4 -p 1666 user -o scobi -param value
    

    Result:

    ERROR: ParameterBindingException:
    p4 : Cannot bind parameter because parameter 'param' is specified more than once. ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
I've got a string that has curly quotes in it. I'd like to replace
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have some data like this: 1 2 3 4 5 9 2 6
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm making a simple page using Google Maps API 3. My first. One marker
Is it possible to replace javascript w/ HTML if JavaScript is not enabled on
I have text I am displaying in SIlverlight that is coming from a CMS
I want to count how many characters a certain string has in PHP, but
I used javascript for loading a picture on my website depending on which small

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.