Are there well-known PowerShell coding conventions?
Posted
by
Tahir Hassan
on Programmers
See other posts from Programmers
or by Tahir Hassan
Published on 2012-10-31T14:23:38Z
Indexed on
2012/10/31
23:16 UTC
Read the original article
Hit count: 344
Are there any well-defined conventions when programming in PowerShell?
For example, in scripts which are to be maintained long-term, do we need to:
- Use the real cmdlet name or alias?
- Specify the cmdlet parameter name in full or only partially (
dir -Recurse
versusdir -r
) - When specifying string arguments for cmdlets do you enclose them in quotes (
New-Object 'System.Int32'
versusNew-Object System.Int32
- When writing functions and filters do you specify the types of parameters?
- Do you write cmdlets in the (official) correct case?
- For keywords like
BEGIN...PROCESS...END
do you write them in uppercase only?
It seems that MSDN lack coding conventions document for PowerShell, while such document exist for example for C#.
© Programmers or respective owner