Skip to content

Commit 574e6df

Browse files
authored
Update type accelerators doc (#11714)
1 parent 1dfc1e6 commit 574e6df

File tree

8 files changed

+216
-56
lines changed

8 files changed

+216
-56
lines changed

reference/5.1/Microsoft.PowerShell.Core/About/About.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
description: About topics cover a range of concepts about PowerShell.
33
Help Version: 6.0
44
Locale: en-US
5-
ms.date: 01/14/2025
5+
ms.date: 01/21/2025
66
title: About topics
77
---
88
# About topics
@@ -583,7 +583,7 @@ terminating errors.
583583

584584
### [about_Type_Accelerators](about_Type_Accelerators.md)
585585

586-
Describes the Type accelerators available for .NET framework classes
586+
Describes the Type accelerators available for .NET types.
587587

588588
### [about_Type_Conversion](about_Type_Conversion.md)
589589

reference/5.1/Microsoft.PowerShell.Core/About/about_Type_Accelerators.md

Lines changed: 51 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,68 @@
11
---
2-
description: Describes the Type accelerators available for .NET framework classes
2+
description: Describes the type accelerators available for .NET types.
33
Locale: en-US
4-
ms.date: 08/30/2023
4+
ms.date: 01/21/2025
55
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_type_accelerators?view=powershell-5.1&WT.mc_id=ps-gethelp
66
schema: 2.0.0
77
title: about_Type_Accelerators
88
---
99
# about_Type_Accelerators
1010

11-
## SHORT DESCRIPTION
12-
Describes the Type accelerators available for .NET framework classes
11+
## Short description
12+
13+
Describes the type accelerators available for .NET types.
1314

1415
## Long description
1516

16-
Type accelerators are aliases for .NET framework classes. They allow you to
17-
access specific .NET framework classes without having to explicitly type the
18-
entire class name. For example, you can shorten the **AliasAttribute**
19-
class from `[System.Management.Automation.AliasAttribute]` to `[Alias]`.
17+
Type accelerators are aliases for .NET types. They allow you to access specific
18+
.NET types without explicitly using the full type name. For example, you can
19+
shorten `[System.Management.Automation.AliasAttribute]` to `[Alias]`.
20+
21+
Type accelerator names are mostly lowercase, but some are defined using
22+
Pascal-case. PowerShell is case-insensitive, so you can use either.
23+
24+
## Using type accelerators
25+
26+
For most type accelerators, you use type accelerators in the same way as
27+
you would use the full type name. However, PowerShell has special handling for
28+
the following two type accelerators:
29+
30+
- `pscustomobject` - See [about_PSCustomObject](about_PSCustomObject.md)
31+
- `ref` - See [about_Ref](about_Ref.md)
32+
33+
Type accelerators are most commonly used to specify the type of a variable or
34+
cast an object to a specific type. For those cases, you must enclose the type
35+
name or its accelerator in square brackets (`[]`). For example, `[int]` or
36+
`[int32]`.
37+
38+
In some contexts, you can specify allow type accelerator name as a string. For
39+
example:
40+
41+
- When used with type comparison operators
42+
43+
```powershell
44+
PS> '1' -as 'int'
45+
1
46+
PS> 1 -is 'int'
47+
True
48+
```
49+
50+
- When used with `[type]` type class
51+
52+
```powershell
53+
PS> [type]'int'
54+
55+
IsPublic IsSerial Name BaseType
56+
-------- -------- ---- --------
57+
True True Int32 System.ValueType
58+
```
2059

21-
> [!NOTE]
22-
> All type accelerators still need to be wrapped in square brackets(`[]`).
60+
In other contexts, like reflection, you must use the full type name as a string
61+
rather than the type accelerator name.
2362

24-
## Available Type Accelerators
63+
## Default type accelerators
2564

26-
| Accelerator | Full Class Name |
65+
| Accelerator name | Full type name |
2766
| ---------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- |
2867
| adsi | [System.DirectoryServices.DirectoryEntry](xref:System.DirectoryServices.DirectoryEntry) |
2968
| adsisearcher | [System.DirectoryServices.DirectorySearcher](xref:System.DirectoryServices.DirectorySearcher) |

reference/7.4/Microsoft.PowerShell.Core/About/About.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
description: About topics cover a range of concepts about PowerShell.
33
Help Version: 7.4.0.0
44
Locale: en-US
5-
ms.date: 01/14/2025
5+
ms.date: 01/21/2025
66
title: About topics
77
---
88
# About topics
@@ -601,7 +601,7 @@ terminating errors.
601601

602602
### [about_Type_Accelerators](about_Type_Accelerators.md)
603603

604-
Describes the Type accelerators available for .NET framework classes
604+
Describes the Type accelerators available for .NET types.
605605

606606
### [about_Type_Conversion](about_Type_Conversion.md)
607607

reference/7.4/Microsoft.PowerShell.Core/About/about_Type_Accelerators.md

Lines changed: 53 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,68 @@
11
---
2-
description: Describes the Type accelerators available for .NET framework classes
2+
description: Describes the type accelerators available for .NET types.
33
Locale: en-US
4-
ms.date: 08/30/2023
4+
ms.date: 01/21/2025
55
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_type_accelerators?view=powershell-7.4&WT.mc_id=ps-gethelp
66
schema: 2.0.0
77
title: about_Type_Accelerators
88
---
99
# about_Type_Accelerators
1010

11-
## SHORT DESCRIPTION
12-
Describes the Type accelerators available for .NET framework classes
11+
## Short description
12+
13+
Describes the type accelerators available for .NET types.
1314

1415
## Long description
1516

16-
Type accelerators are aliases for .NET framework classes. They allow you to
17-
access specific .NET framework classes without having to explicitly type the
18-
entire class name. For example, you can shorten the **AliasAttribute**
19-
class from `[System.Management.Automation.AliasAttribute]` to `[Alias]`.
17+
Type accelerators are aliases for .NET types. They allow you to access specific
18+
.NET types without explicitly using the full type name. For example, you can
19+
shorten `[System.Management.Automation.AliasAttribute]` to `[Alias]`.
20+
21+
Type accelerator names are mostly lowercase, but some are defined using
22+
Pascal-case. PowerShell is case-insensitive, so you can use either.
23+
24+
## Using type accelerators
25+
26+
For most type accelerators, you use type accelerators in the same way as
27+
you would use the full type name. However, PowerShell has special handling for
28+
the following two type accelerators:
29+
30+
- `pscustomobject` - See [about_PSCustomObject](about_PSCustomObject.md)
31+
- `ref` - See [about_Ref](about_Ref.md)
32+
33+
Type accelerators are most commonly used to specify the type of a variable or
34+
cast an object to a specific type. For those cases, you must enclose the type
35+
name or its accelerator in square brackets (`[]`). For example, `[int]` or
36+
`[int32]`.
37+
38+
In some contexts, you can specify allow type accelerator name as a string. For
39+
example:
40+
41+
- When used with type comparison operators
42+
43+
```powershell
44+
PS> '1' -as 'int'
45+
1
46+
PS> 1 -is 'int'
47+
True
48+
```
49+
50+
- When used with `[type]` type class
51+
52+
```powershell
53+
PS> [type]'int'
54+
55+
IsPublic IsSerial Name BaseType
56+
-------- -------- ---- --------
57+
True True Int32 System.ValueType
58+
```
2059

21-
> [!NOTE]
22-
> All type accelerators still need to be wrapped in square brackets(`[]`).
60+
In other contexts, like reflection, you must use the full type name as a string
61+
rather than the type accelerator name.
2362

24-
## Available Type Accelerators
63+
## Default type accelerators
2564

26-
| Accelerator | Full Class Name |
65+
| Accelerator name | Full type name |
2766
| ---------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- |
2867
| adsi | [System.DirectoryServices.DirectoryEntry](xref:System.DirectoryServices.DirectoryEntry) |
2968
| adsisearcher | [System.DirectoryServices.DirectorySearcher](xref:System.DirectoryServices.DirectorySearcher) |
@@ -66,6 +105,7 @@ class from `[System.Management.Automation.AliasAttribute]` to `[Alias]`.
66105
| IPEndpoint | [System.Net.IPEndPoint](xref:System.Net.IPEndPoint) |
67106
| long | [System.Int64](xref:System.Int64) |
68107
| mailaddress | [System.Net.Mail.MailAddress](xref:System.Net.Mail.MailAddress) |
108+
| NoRunspaceAffinity | [System.Management.Automation.Language.NoRunspaceAffinityAttribute](xref:System.Management.Automation.Language.NoRunspaceAffinityAttribute) |
69109
| NullString | [System.Management.Automation.Language.NullString](xref:System.Management.Automation.Language.NullString) |
70110
| ObjectSecurity | [System.Security.AccessControl.ObjectSecurity](xref:System.Security.AccessControl.ObjectSecurity) |
71111
| ordered | [System.Collections.Specialized.OrderedDictionary](xref:System.Collections.Specialized.OrderedDictionary) |
@@ -115,6 +155,7 @@ class from `[System.Management.Automation.AliasAttribute]` to `[Alias]`.
115155
| ValidateLength | [System.Management.Automation.ValidateLengthAttribute](xref:System.Management.Automation.ValidateLengthAttribute) |
116156
| ValidateNotNull | [System.Management.Automation.ValidateNotNullAttribute](xref:System.Management.Automation.ValidateNotNullAttribute) |
117157
| ValidateNotNullOrEmpty | [System.Management.Automation.ValidateNotNullOrEmptyAttribute](xref:System.Management.Automation.ValidateNotNullOrEmptyAttribute) |
158+
| ValidateNotNullOrWhiteSpace | [System.Management.Automation.ValidateNotNullOrWhiteSpaceAttribute](xref:System.Management.Automation.ValidateNotNullOrWhiteSpaceAttribute) |
118159
| ValidatePattern | [System.Management.Automation.ValidatePatternAttribute](xref:System.Management.Automation.ValidatePatternAttribute) |
119160
| ValidateRange | [System.Management.Automation.ValidateRangeAttribute](xref:System.Management.Automation.ValidateRangeAttribute) |
120161
| ValidateScript | [System.Management.Automation.ValidateScriptAttribute](xref:System.Management.Automation.ValidateScriptAttribute) |

reference/7.5/Microsoft.PowerShell.Core/About/About.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
description: About topics cover a range of concepts about PowerShell.
33
Help Version: 7.5.0.0
44
Locale: en-US
5-
ms.date: 01/14/2025
5+
ms.date: 01/21/2025
66
title: About topics
77
---
88
# About topics
@@ -601,7 +601,7 @@ terminating errors.
601601

602602
### [about_Type_Accelerators](about_Type_Accelerators.md)
603603

604-
Describes the Type accelerators available for .NET framework classes
604+
Describes the Type accelerators available for .NET types.
605605

606606
### [about_Type_Conversion](about_Type_Conversion.md)
607607

reference/7.5/Microsoft.PowerShell.Core/About/about_Type_Accelerators.md

Lines changed: 52 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,68 @@
11
---
2-
description: Describes the Type accelerators available for .NET framework classes
2+
description: Describes the type accelerators available for .NET types.
33
Locale: en-US
4-
ms.date: 08/30/2023
4+
ms.date: 01/21/2025
55
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_type_accelerators?view=powershell-7.5&WT.mc_id=ps-gethelp
66
schema: 2.0.0
77
title: about_Type_Accelerators
88
---
99
# about_Type_Accelerators
1010

11-
## SHORT DESCRIPTION
11+
## Short description
1212

13-
Describes the Type accelerators available for .NET framework classes
13+
Describes the type accelerators available for .NET types.
1414

1515
## Long description
1616

17-
Type accelerators are aliases for .NET framework classes. They allow you to
18-
access specific .NET framework classes without having to explicitly type the
19-
entire class name. For example, you can shorten the **AliasAttribute**
20-
class from `[System.Management.Automation.AliasAttribute]` to `[Alias]`.
17+
Type accelerators are aliases for .NET types. They allow you to access specific
18+
.NET types without explicitly using the full type name. For example, you can
19+
shorten `[System.Management.Automation.AliasAttribute]` to `[Alias]`.
2120

22-
> [!NOTE]
23-
> All type accelerators still need to be wrapped in square brackets(`[]`).
21+
Type accelerator names are mostly lowercase, but some are defined using
22+
Pascal-case. PowerShell is case-insensitive, so you can use either.
2423

25-
## Available Type Accelerators
24+
## Using type accelerators
2625

27-
| Accelerator | Full Class Name |
26+
For most type accelerators, you use type accelerators in the same way as
27+
you would use the full type name. However, PowerShell has special handling for
28+
the following two type accelerators:
29+
30+
- `pscustomobject` - See [about_PSCustomObject](about_PSCustomObject.md)
31+
- `ref` - See [about_Ref](about_Ref.md)
32+
33+
Type accelerators are most commonly used to specify the type of a variable or
34+
cast an object to a specific type. For those cases, you must enclose the type
35+
name or its accelerator in square brackets (`[]`). For example, `[int]` or
36+
`[int32]`.
37+
38+
In some contexts, you can specify allow type accelerator name as a string. For
39+
example:
40+
41+
- When used with type comparison operators
42+
43+
```powershell
44+
PS> '1' -as 'int'
45+
1
46+
PS> 1 -is 'int'
47+
True
48+
```
49+
50+
- When used with `[type]` type class
51+
52+
```powershell
53+
PS> [type]'int'
54+
55+
IsPublic IsSerial Name BaseType
56+
-------- -------- ---- --------
57+
True True Int32 System.ValueType
58+
```
59+
60+
In other contexts, like reflection, you must use the full type name as a string
61+
rather than the type accelerator name.
62+
63+
## Default type accelerators
64+
65+
| Accelerator name | Full type name |
2866
| ---------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- |
2967
| adsi | [System.DirectoryServices.DirectoryEntry](xref:System.DirectoryServices.DirectoryEntry) |
3068
| adsisearcher | [System.DirectoryServices.DirectorySearcher](xref:System.DirectoryServices.DirectorySearcher) |
@@ -67,6 +105,7 @@ class from `[System.Management.Automation.AliasAttribute]` to `[Alias]`.
67105
| IPEndpoint | [System.Net.IPEndPoint](xref:System.Net.IPEndPoint) |
68106
| long | [System.Int64](xref:System.Int64) |
69107
| mailaddress | [System.Net.Mail.MailAddress](xref:System.Net.Mail.MailAddress) |
108+
| NoRunspaceAffinity | [System.Management.Automation.Language.NoRunspaceAffinityAttribute](xref:System.Management.Automation.Language.NoRunspaceAffinityAttribute) |
70109
| NullString | [System.Management.Automation.Language.NullString](xref:System.Management.Automation.Language.NullString) |
71110
| ObjectSecurity | [System.Security.AccessControl.ObjectSecurity](xref:System.Security.AccessControl.ObjectSecurity) |
72111
| ordered | [System.Collections.Specialized.OrderedDictionary](xref:System.Collections.Specialized.OrderedDictionary) |
@@ -116,6 +155,7 @@ class from `[System.Management.Automation.AliasAttribute]` to `[Alias]`.
116155
| ValidateLength | [System.Management.Automation.ValidateLengthAttribute](xref:System.Management.Automation.ValidateLengthAttribute) |
117156
| ValidateNotNull | [System.Management.Automation.ValidateNotNullAttribute](xref:System.Management.Automation.ValidateNotNullAttribute) |
118157
| ValidateNotNullOrEmpty | [System.Management.Automation.ValidateNotNullOrEmptyAttribute](xref:System.Management.Automation.ValidateNotNullOrEmptyAttribute) |
158+
| ValidateNotNullOrWhiteSpace | [System.Management.Automation.ValidateNotNullOrWhiteSpaceAttribute](xref:System.Management.Automation.ValidateNotNullOrWhiteSpaceAttribute) |
119159
| ValidatePattern | [System.Management.Automation.ValidatePatternAttribute](xref:System.Management.Automation.ValidatePatternAttribute) |
120160
| ValidateRange | [System.Management.Automation.ValidateRangeAttribute](xref:System.Management.Automation.ValidateRangeAttribute) |
121161
| ValidateScript | [System.Management.Automation.ValidateScriptAttribute](xref:System.Management.Automation.ValidateScriptAttribute) |

reference/7.6/Microsoft.PowerShell.Core/About/About.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
description: About topics cover a range of concepts about PowerShell.
33
Help Version: 7.6.0.0
44
Locale: en-US
5-
ms.date: 01/14/2025
5+
ms.date: 01/21/2025
66
title: About topics
77
---
88
# About topics
@@ -601,7 +601,7 @@ terminating errors.
601601

602602
### [about_Type_Accelerators](about_Type_Accelerators.md)
603603

604-
Describes the Type accelerators available for .NET framework classes
604+
Describes the Type accelerators available for .NET types.
605605

606606
### [about_Type_Conversion](about_Type_Conversion.md)
607607

0 commit comments

Comments
 (0)