I am working on a powershell module that has many cmdlets. I've been asked if we can add something to the cmdlets to prevent namespace collisions between modules. One thing that has been proposed if we could add something before the verb. ex. dotnet build
. Basically is it possible to put something that would be customname add-newitem
? I've looked into qualified module names, but that is a bit clunky.
I've also looked into the manifest file defaultcommandprefix, and that does work, but the prefix is still after the verb.
Each PowerShell cmdlet can be address by its friendly name, e.g. Get-Item
(or an alias, like gi
in this case) or by its full qualified name which is basically: <source>\<name>
.
Get-Command Get-Item
CommandType Name Version Source
----------- ---- ------- ------
Cmdlet Get-Item 7.0.0.0 Microsoft.PowerShell.Management
Meaning you can also address the specific cmdlet like this:
Microsoft.PowerShell.Management\Get-Item -Path .\Test
For custom module the source is the module name, e.g.:
Install-Module -Name JoinModule
Get-Command Join-Object
CommandType Name Version Source
----------- ---- ------- ------
Function Join-Object 3.7.2 JoinModule
JoinObject\Join-Object ...
This basically means that there shouldn't be any need to manually prefix cmdlets with module (or customer) names. Besides there are clear verb-noun
naming recommendations that even define a difference between e.g. New-Item
and Add-Item
. Nevertheless, if you want to be specific on an identity, the naming convention often used is: <verb>-<identity><noun>
, e.g. Get-ADUser
or even Get-AzureADUser
.