Parameter Name should be in Upper Case

Welcome Forums General PowerShell Q&A Parameter Name should be in Upper Case

This topic contains 3 replies, has 4 voices, and was last updated by

2 years, 2 months ago.

  • Author
  • #56963

    Points: 0
    Rank: Member

    Is this possible.
    I have created a custom function called New-File

    Function New-File {
    New-Item -Name $Name -Path $Path -ItemType File

    If the Parameter Path or Name is type by the user in lower case, it should not work.

    This should work
    New-File -Path E:\ -Name Testing

    This should not work. As the path parameter is type in lower case.
    New-File -path E:\ -Name Testing

    I tried using $PSBoundParameters but failed. Is there a way to do this.

    Reason: My Client want it this way.

  • #56965

    Points: 0
    Rank: Member

    PowerShell is by design case insensitive so I doubt this is possible. case sensitivity for parameters doesn't make any sense

    • #56968

      Points: 420
      Helping Hand
      Rank: Contributor

      So you might ask your client what's the advantage of having case sensitive parameter names. IMHO that's the most futile request I have ever heard of.

  • #57037

    Points: 2
    Rank: Member

    The only way you'll likely accomplish this is to do your own argument processing.

    function test_args()
      Write-Host "arg 0:  $($args[0])"
      Write-Host "arg 1:  $($args[1])"
    test_args -File "Name"

The topic ‘Parameter Name should be in Upper Case’ is closed to new replies.