While I did find a lot of information on how to name Cmdlets and functions in the Cmdlet Development Guidelines I did not find any information on whether functions should be named in upper or in lower case.
What is the convention here?
(I do understand that Cmdlets themselves are generally named in upper case, even though they are not case-sensitive when it comes to executing.)
A cmdlet -- pronounced command-let -- is a small, lightweight command that is used in the Windows PowerShell environment. A cmdlet typically exists as a small script that is intended to perform a single specific function such as coping files and changing directories.
Parsing, error presentation, and output formatting are not handled by cmdlets. It is done by the Windows PowerShell runtime. Explanation: All of the above is true about Cmdlet.
A cmdlet is a single command that participates in the pipeline semantics of PowerShell. This includes binary cmdlets, advanced script functions, CDXML, and Workflows. Advanced functions allow you create cmdlets that are written as a PowerShell function.
The building blocks of Powershell: cmdlets The three most important characteristics are: Cmdlets output results as an object or as an array of objects. Cmdlets can get data for analysis or transfer data to another cmdlet using pipes. Cmdlets are case-insensitive.
Naming convention can be tricky. While a fixed naming convention may provide aesthetics or simplified usage, it is not required to be followed. In general, a naming convention that I advocate for is the one that is used already in Powershell. As functions are created on verb-noun base, each word starts with a capital letter or if it is an abbreviation - all capitals, or if it is a proprietary - then as it is accordingly.
I have, for example, created some functions for myself:
Get-ServerDiag
Mount-TrueCryptVolumes
Start-RDP
Generate-RandomPassword
Nuke-Environment
You can imagine what these functions do, it is rather clear, straightforward and compliant with built-in Powershell functions. I do however have exceptions which come from "importing" a several Unix commands to Powershell (like killall
, pidof
etc...) You can always use a Set-Alias
if you prefer to write something else.
This question, however important, is discussable as there does not seem to be the 'one, best way'. It is all, in the end, up to personal preferences.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With