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 7916733
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T14:54:41+00:00 2026-06-03T14:54:41+00:00

Referring this link, I am trying to introduce verbose mode in my script. When

  • 0

Referring this link, I am trying to introduce verbose mode in my script.

When I have a function defined like this –

function TestVerbose
{
    param(
        [switch]$verbose,
        [Parameter(Mandatory = $True)] 
        $p1
    )

    if($verbose)
    {
     Write-Verbose "Verbose Mode"
    }
}

Get-Help TestVerbose

I get the following error –

Get-Help : A parameter with the name ‘Verbose’ was defined multiple
times for the command. At line:12 char:9
+ Get-Help <<<< TestVerbose
+ CategoryInfo : MetadataError: (:) [Get-Help], MetadataException
+ FullyQualifiedErrorId : ParameterNameAlreadyExistsForCommand,Microsoft.PowerShell.Commands.GetHelpCommand

BUT, if I define the function like this [removing the parameter mandatory attribute], it works fine

function TestVerbose
{
    param(
        [switch]$verbose,
        $p1
    )
    if($verbose)
    {
     Write-Verbose "Verbose Mode"
    }    
}

Get-Help TestVerbose

Any idea why such a behaviour ? I want to keep the mandatory switch and want the user to execute my function like this –

TestVerbose -verbose

  • 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-06-03T14:54:44+00:00Added an answer on June 3, 2026 at 2:54 pm

    It appears you are using PoweShell v2, in which Verbose (along with debug, whatif, etc) are reserved and their functions automatically provided for you. Instead of writing your own ‘verbose’ detection switch, the functionality is already there. In the case of verbose you don’t have to specify it in the parameter declaration, other parameters likes whatif require special synatax.

    C:\Users\james> function testverbose{
    >>     param(
    >>         [Parameter(Mandatory = $True)]
    >>         $bar
    >>     )
    >>
    >>     Write-Verbose "VERBOSE!"
    >>     $bar
    >> }
    >>
    C:\Users\james> testverbose -bar "woot"
    woot
    C:\Users\james> testverbose -bar "woot" -Verbose
    VERBOSE: VERBOSE!
    woot
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have tried to do this refering to following link. http://skypher.com/index.php/2008/07/28/function-list-for-php/ But no success.
Here is a link to the tutorial that I am referring to. This seems
i'm referring this address for function olLiTree PHP function that creates a nested ul
I have declared my model classes as found in this link ....I now want
By referring to this link I try to implement this powerful tool and facing
When trying to solve this problem , I encountered some articles, etc. referring to
I published a simple ASP.net website referring to this link : http://msdn.microsoft.com/en-us/library/1y1404zt%28v=vs.80%29.aspx I managed
I have a problem with two sides of my site, this is the link
I'm referring to this link here: sortable I want to make these items inline,
Alright with the way below it is extracting only referring url like this the

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.