Naming convention for Improved module and cmdlets

Welcome Forums General PowerShell Q&A Naming convention for Improved module and cmdlets

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

1 year, 3 months ago.

  • Author
  • #83438

    Points: 311
    Helping Hand
    Rank: Contributor

    I can find guidelines about the naming convention for new cmdlets and new modules.

    But what about an improved cmdlet of an existing module.
    For example, let's say I want to improve the Get-SmbShare cmdlet from the SmbShare module by adding a new parameter to the cmdlet.
    How could I name my module?

    • SmbShare2
    • SmbShareExtended
    • SmbShareImproved
    • ...

    Same question for the cmdlet inside the module. How could I name it?
    I've seen for example a Get-ChildItem2 cmdlet.

    I couldn't find any official guidelines about that...

  • #83440

    Points: 740
    Helping Hand
    Rank: Major Contributor

    If you have a little time left you could watch this video ... the relevant part is in the last quarter if I remember right ... have fun!

    I guess they called it proxy cmdlet or cmdlet proxy or something like this.

  • #83446

    Points: 1
    Rank: Member

    I've used two approaches that are my own home-spun-ideas (certainly not guidelines):

    1: Append an M to the command for improved, akin to vim for vi in Unix. So Verb-NounM
    2: I've "broken the rules" for one lone command which has really no impact as I'm the only person that uses the function. It's my exception to the Verb-Noun rule. Explained:

    I used to alias cvi to Connect-VIServer. One day I elected to add the functionality of putting the VIServer I'm connect{ing,ed} to in the title bar as I maintain several Virtual Centers. Yes, I prefer to set PowerCLI to Single VIServer Mode and have a separate window for each. Or, if I disconnect from one and connect to another, the correct Virtual Center is reflected in the title bar. Crude but effective (per my buddy Darth).

    Ergo I made the function below to a) add functionality to the command and b) maintain my "alias". I know this isn't textbook and if someone has a better idea, I'm all for it.

    function cvi
    Connect-VIServer -Server $args[0]
    $host.ui.RawUI.WindowTitle = $global:DefaultVIServer

  • #83464

    Points: 1
    Rank: Member

    My favorite method for customized cmdlets is to add a prefix to the noun. Like your initials, or a company stock symbol, or something like that. So Get-LFSMBShare and Set-LFSMBShare. The benefit to that method is in command discovery. Get-LF will autocomplete through all of your customized cmdlets. Seems easier to find too when you're doing things like get-command, etc.

  • #83639

    Points: 311
    Helping Hand
    Rank: Contributor

    Thanks all for your suggestions! 🙂

The topic ‘Naming convention for Improved module and cmdlets’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort