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

  • Home
  • SEARCH
  • 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 6228105
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T09:19:56+00:00 2026-05-24T09:19:56+00:00

If I define the following [parameter(Mandatory = $true)] [alias(db)] [string]$database, then I get an

  • 0

If I define the following

[parameter(Mandatory = $true)]
[alias("db")]
[string]$database,

then I get an error

Parameter alias cannot be specified because an alias with the name 'db'
was defined multiple times for the command.

Which is true, since db is already an alias for the universal -Debug parameter.
Is it possible to define this alias without renaming the parameter?

  • 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-24T09:19:56+00:00Added an answer on May 24, 2026 at 9:19 am

    Sorry, you can’t. -Debug is a common parameter, so -Debug and -db are switches that are available on pretty much everything including the functions you write yourself. As the error tells you, it’s already defined.

    Even if it were possible to go around undefining built-in aliases, that unexpectantly changes the meaning of a call like test-db -db for someone else who frequently uses -db instead of -Debug. They expect it to enable debugging output, not specify a different parameter.

    Consider this function:

    function test-db{
      param(
        [parameter(mandatory=$true)]
        [string]$database)
      write-host 'database' $database
      write-debug 'debugging output'
    }
    

    Now call it with test-db server, test-db -db server, and test-db server -db. The first doesn’t do write-debug, while the other 2 do, no matter where -db is. You also can’t define a separate parameter [string]$db (or rename $database to $db) because Powershell will give you this error:

    Parameter ‘db’ cannot be specified because it conflicts with the parameter alias of the same name for parameter ‘Debug’.

    More info on this, per MSDN (updated since old link died):

    In addition to using the System.Management.Automation.Aliasattribute attribute, the Windows PowerShell runtime performs partial name matching, even if no aliases are specified. For example, if your cmdlet has a FileName parameter and that is the only parameter that starts with F, the user could enter Filename, Filenam, File, Fi, or F and still recognize the entry as the FileName parameter.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to define a following function: if(stmtToFinalize) { NSLog(@Finalizing statement stmtToFinalize); if (sqlite3_finalize(stmtToFinalize)
I wish to define the following typeclass Mapping : {-# LANGUAGE MultiParamTypeClasses #-} class
I have the following items (define itemslist (list 'a1 'b2 'c3 (list 'z1 'z2)
For instance, is the following possible: #define definer(x) #define #x?
The following code works fine #define open { #define close } #include<stdio.h> #define int
I have the following struct in C++: #define MAXCHARS 15 typedef struct { char
I have the following C code: #define PRR_SCALE 255 ... uint8_t a = 3;
I have the following preprocessor divective: #ifndef NDEBUG #define TRACE printf #else #define TRACE(...)
I have the following situation: A user will define a certain filter on a
If I have the following: /* * example.h */ #ifndef EXAMPLE #define EXAMPLE #include

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.