Skip to content

Commit 80abe23

Browse files
sdwheelerCopilotsurfingoldelephant
authored
Define common terminology and styling (#12632)
* Define common terminology and styling * Apply suggestions from code review Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Add not about Env: * Add section for $_/$PSItem * Apply suggestions from code review Co-authored-by: surfingoldelephant <151538956+surfingoldelephant@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: surfingoldelephant <151538956+surfingoldelephant@users.noreply.github.com> * Update terminology.md Co-authored-by: surfingoldelephant <151538956+surfingoldelephant@users.noreply.github.com> * More feedback edits * Add TabExpansion2 example --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: surfingoldelephant <151538956+surfingoldelephant@users.noreply.github.com>
1 parent 5d54677 commit 80abe23

File tree

1 file changed

+241
-0
lines changed

1 file changed

+241
-0
lines changed

terminology.md

Lines changed: 241 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,241 @@
1+
---
2+
ms.date: 01/05/2026
3+
---
4+
# Terminology and format guidelines
5+
6+
When writing about PowerShell, use the following terminology guidelines to ensure consistency across
7+
documentation. This is a draft document that's subject to change. Eventually, we will move this
8+
content to the PowerShell-Docs style guide.
9+
10+
## Punctuation
11+
12+
For general rules, see [Punctuation - Microsoft Style Guide][01].
13+
14+
For PowerShell-specific terminology, see [PowerShell-Docs style guide][03].
15+
16+
### Hyphenation
17+
18+
See [Hyphens - Microsoft Style Guide][08].
19+
20+
In general, don't include a hyphen after prefixes unless omitting the hyphen could confuse the
21+
reader. See the style guide for specific examples.
22+
23+
- _subexpression_ not _sub-expression_
24+
25+
Hyphenate two or more words that precede and modify a noun.
26+
27+
- dot-source
28+
29+
Use the _dot-source operator_ to _dot-source_ a script.
30+
31+
- _built-in_ drive
32+
- _high-level-language_ compiler
33+
- _member-access_ operator
34+
35+
## Capitalization and space conventions
36+
37+
For general guidelines, see [Capitalization - Microsoft Style Guide][07]. For PowerShell:
38+
39+
Microsoft product names have specific capitalization requirements that must be followed. See
40+
[Microsoft Product Style Guide][05].
41+
42+
All keywords should be lowercase and backticked in a paragraph. See [about_Language_Keywords][02].
43+
When referring to statements that consist of multiple keywords, use slashes to separate the
44+
keywords rather than spaces or dashes.
45+
46+
- `do/until`
47+
- `do/while`
48+
- `try/catch/finally`
49+
- `if/elseif/else`
50+
51+
Example:
52+
53+
> A `do/until` loop consists of a `do` statement block followed by `until` and a
54+
> conditional expression.
55+
56+
Command names and parameters usually use PascalCase, but verify the correct casing by inspecting the
57+
command definitions.
58+
59+
For example, the parameters of the `TabExpansion2` function don't use PascalCase:
60+
61+
```powershell
62+
TabExpansion2 -inputScript "TabExpansion2 -" | Select-Object -ExpandProperty CompletionMatches
63+
```
64+
65+
```Output
66+
CompletionText ListItemText ResultType ToolTip
67+
-------------- ------------ ---------- -------
68+
-inputScript inputScript ParameterName [string] inputScript
69+
-cursorColumn cursorColumn ParameterName [int] cursorColumn
70+
-ast ast ParameterName [Ast] ast
71+
-tokens tokens ParameterName [Token[]] tokens
72+
-positionOfCursor positionOfCursor ParameterName [IScriptPosition] positionOfCursor
73+
-options options ParameterName [hashtable] options
74+
-Verbose Verbose ParameterName [switch] Verbose
75+
-Debug Debug ParameterName [switch] Debug
76+
-ErrorAction ErrorAction ParameterName [ActionPreference] ErrorAction
77+
-WarningAction WarningAction ParameterName [ActionPreference] WarningAction
78+
-InformationAction InformationAction ParameterName [ActionPreference] InformationAction
79+
-ProgressAction ProgressAction ParameterName [ActionPreference] ProgressAction
80+
-ErrorVariable ErrorVariable ParameterName [string] ErrorVariable
81+
-WarningVariable WarningVariable ParameterName [string] WarningVariable
82+
-InformationVariable InformationVariable ParameterName [string] InformationVariable
83+
-OutVariable OutVariable ParameterName [string] OutVariable
84+
-OutBuffer OutBuffer ParameterName [int] OutBuffer
85+
-PipelineVariable PipelineVariable ParameterName [string] PipelineVariable
86+
```
87+
88+
### Specific examples
89+
90+
- _file system_
91+
- _file name_
92+
- _localhost_ - lowercase
93+
- _CIM session_ - refers to the concept of a CIM session
94+
- _CimSession_ - refers to the PowerShell object of type `[CimSession]`
95+
- _PSSnapin_ - refers to an instance of a PowerShell snap-in assembly (such as
96+
Microsoft.PowerShell.Core)
97+
- _snap-in_ - the general term for a PowerShell snap-in assembly
98+
- _SDDL_ - abbreviation of Security Descriptor Definition Language
99+
- _WSMan_ and _WinRM_
100+
- _WSMan_ - Microsoft's abbreviation for the WS-Management (Web Services-Management) open standard
101+
- _WinRM_ - Windows Remote Management - Microsoft's implementation of the WSMan standard
102+
- Use lowercase instances only where the name is lowercase in the service interfaces (such as
103+
`winrm` command-line tool, or in schema URIs and other properties).
104+
- Variable scopes and scope modifiers
105+
106+
See [Appendix A - Grammar - B.1.6 Variables][04].
107+
108+
Scope names and modifiers are capitalized:
109+
110+
- `Global:` and **Global** scope
111+
- `Local:` and **Local** scope
112+
- `Script:` and **Script** scope
113+
- `Private:`
114+
- `Using:`
115+
- `Workflow:`
116+
117+
PowerShell drive names such as `Env` are capitalized.
118+
119+
```powershell
120+
Get-Item -Path Env:COMPUTERNAME
121+
122+
Name Value
123+
---- -----
124+
COMPUTERNAME COMPUTER01
125+
```
126+
127+
`Env` is a special case when used in variable namespace notation.
128+
Use lowercase for `$env:`. For all other PowerShell drives, use normal
129+
capitalization.
130+
131+
```powershell
132+
$env:COMPUTERNAME
133+
COMPUTER01
134+
135+
$Alias:dir
136+
Get-ChildItem
137+
```
138+
139+
## Terms
140+
141+
### Declare vs. initialize
142+
143+
_Initialize_ is the correct term to use when referring to assigning a value to a variable for the
144+
first time.
145+
146+
The `New-Variable` cmdlet is used to declare variables. This is the only way to create a variable
147+
without a value. When you don't provide a value, the value is set to `$null` by default.
148+
149+
When you reference a variable that hasn't been declared yet (such as `$var`) for the first time,
150+
PowerShell creates the variable. If you didn't initialize the variable, PowerShell assigns a default
151+
value depending on its type. Variables that are not explicitly typed are assigned a value of
152+
`$null`. In practice, it's difficult to create a variable without initializing it.
153+
154+
### Native vs. external commands
155+
156+
Not all external commands are native commands. A PowerShell script can be an _external command_, but
157+
it's not a native command.
158+
159+
_Native commands_ are executables that can be run from any shell or other invocation method
160+
supported by the OS.
161+
162+
### Scalar vs. single vs. singleton
163+
164+
See [Scalar data type - Wikipedia][10].
165+
166+
A scalar data type, or just scalar, is any non-composite value.
167+
168+
Generally, all basic primitive data types are considered scalar:
169+
170+
- The Boolean data type (bool)
171+
- Numeric types (int, the floating point types float and double)
172+
- Character types (char)
173+
174+
The term _single_ should only refer to a single-precision floating point type `[single]`.
175+
176+
A _singleton_ is a single instance of an object that may be scalar or complex.
177+
178+
## Language elements and terms
179+
180+
### Null values
181+
182+
See [null, NULL, Null - Microsoft Style Guide][06].
183+
184+
Use lowercase _null_ to refer to a null value. Better yet, use _null value_ to avoid confusion with
185+
the constant.
186+
187+
Use `$null`, `NULL`, or `Null` (depending on the language context) only to refer to the constant.
188+
Use `DBNull` to refer to the `[System.DBNull]` type.
189+
190+
### Boolean values
191+
192+
It's preferred to use `$true` and `$false` (all lowercase) when referring to the boolean values.
193+
Alternatively, you can ise _FALSE_ or _TRUE_ (all uppercase) to refer to boolean values in general
194+
writing. Showing boolean values in output should always match the output. For example:
195+
196+
```powershell
197+
PS> $true
198+
True
199+
```
200+
201+
### Hash tables
202+
203+
- Use _hash table_ (two words, all lowercase) to refer to the computer science concept in general
204+
writing. See [Hash table - Wikipedia][09].
205+
- Use _hashtable_ (all lowercase) when referring to the PowerShell objects of type `[hashtable]`.
206+
May be capitalized as _Hashtable_ when it begins a sentence.
207+
- `[hashtable]` (with backticks) when referring to the type more specifically.
208+
- Full type names should match the .NET definition: `[System.Collections.Hashtable]`
209+
210+
### Statements and script blocks
211+
212+
A _script block_ is a generic description we have used historically, but can be a source of
213+
confusion. Use the following terminology instead:
214+
215+
- A _statement block_ refers to `{}` expressions in a statement. This is how the AST refers to
216+
them. Statement blocks don't take parameters or create new scopes.
217+
- _scriptblock_ should be used to refer to `{}` expressions of type `[scriptblock]`. For example,
218+
the **FilterScript** parameter of `Where-Object` expects a scriptblock. Scriptblocks can take
219+
parameters and create new scopes.
220+
221+
### `$_` vs. `$PSItem`
222+
223+
`$_` and `$PSItem` are automatic variables that refer to the current object in the pipeline.
224+
Technically, neither variable is an alias. Both variables contain the same value.
225+
226+
`$PSItem` was added to PowerShell later in an attempt to provide a clearer purpose to the name.
227+
However in practice, the _dollar underscore_ form `$_` is most commonly used.
228+
229+
`$_` is the preferred usage.
230+
231+
<!-- link references -->
232+
[01]: https://learn.microsoft.com/en-us/style-guide/punctuation/
233+
[02]: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_language_keywords
234+
[03]: https://learn.microsoft.com/powershell/scripting/community/contributing/powershell-style-guide
235+
[04]: https://learn.microsoft.com/powershell/scripting/lang-spec/chapter-15#b16-variables
236+
[05]: https://learn.microsoft.com/product-style-guide-msft-internal/welcome/
237+
[06]: https://learn.microsoft.com/style-guide/a-z-word-list-term-collections/n/null
238+
[07]: https://learn.microsoft.com/style-guide/capitalization
239+
[08]: https://learn.microsoft.com/style-guide/punctuation/dashes-hyphens/hyphens
240+
[09]: https://wikipedia.org/wiki/Hash_table
241+
[10]: https://wikipedia.org/wiki/Scalar_processor#Scalar_data_type

0 commit comments

Comments
 (0)