Skip to content

Commit 19bb729

Browse files
Merge pull request #12886 from MicrosoftDocs/main
Auto Publish – main to live - 2026-03-24 22:00 UTC
2 parents 4d5994f + b9ffc89 commit 19bb729

File tree

21 files changed

+436
-78
lines changed

21 files changed

+436
-78
lines changed

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

Lines changed: 58 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
description: Describes arrays, which are data structures designed to store collections of items.
33
Locale: en-US
4-
ms.date: 01/18/2026
4+
ms.date: 03/24/2026
55
no-loc: [Count, Length, LongLength, Rank, ForEach, Clear, Default, First, Last, SkipUntil, Until, Split, Tuple]
66
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_arrays?view=powershell-5.1&WT.mc_id=ps-gethelp
77
schema: 2.0.0
@@ -583,12 +583,67 @@ every item in the collection.
583583
Wednesday, June 20, 2018 9:21:57 AM
584584
```
585585

586+
> [!NOTE]
587+
> The `ForEach()` method wraps properties into a collection before enumeration.
588+
> Using `ForEach()` normally returns all items in both array. However, if you
589+
> want to access elements of the wrapped collection, you need to use two
590+
> indices.
591+
592+
Consider the following example where the object `$myObject` has a property with
593+
single value and a property containing an array of 11 integers.
594+
595+
```powershell
596+
$myObject = [pscustomobject]@{
597+
singleValue = 'Hello'
598+
arrayValue = @(0..10)
599+
}
600+
```
601+
602+
When you use the `ForEach()` method to access a property of the object, the
603+
property is wrapped in a collection.
604+
605+
```powershell
606+
PS> $myObject.ForEach('singleValue').GetType().Name
607+
Collection`1
608+
PS> $myObject.ForEach('singleValue')[0].GetType().Name
609+
String
610+
PS> $myObject.ForEach('singleValue') # Enumerate the collection object
611+
Hello
612+
```
613+
614+
To access the an element of the array, you need to use two indices.
615+
616+
```powershell
617+
PS> $myObject.ForEach('arrayValue').GetType().Name
618+
Collection`1
619+
# A single Collection item
620+
PS> $myObject.ForEach('arrayValue').Count
621+
1
622+
# First item in the collection is an array of 11 items
623+
PS> $myObject.ForEach('Value')[0].Count
624+
11
625+
# Access the first item in the array of 11 items
626+
PS> $myObject.ForEach('Value')[0][0]
627+
0
628+
```
629+
630+
This is different than using the `ForEach()` method using with a scriptblock to
631+
access the **Value** property of each object.
632+
633+
```powershell
634+
PS> $myObject.ForEach({$_.Value}).Count # An array of 11 items
635+
11
636+
```
637+
638+
Use the scriptblock syntax to avoid the wrapping behavior when you want to
639+
access complex property types, such as arrays or nested objects.
640+
586641
#### ForEach(string methodName)
587642

588643
#### ForEach(string methodName, object[] arguments)
589644

590-
Lastly, `ForEach()` methods can be used to execute a method on every item in
591-
the collection.
645+
You can use the `ForEach()` method to execute an object's method on every item
646+
in the collection.
592647

593648
```powershell
594649
("one", "two", "three").ForEach("ToUpper")

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
description: Describes the operators that are supported by PowerShell.
33
Locale: en-US
4-
ms.date: 01/18/2026
4+
ms.date: 03/24/2026
55
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_operators?view=powershell-5.1&WT.mc_id=ps-gethelp
66
schema: 2.0.0
77
title: about_Operators
@@ -301,7 +301,7 @@ At line:1 char:2
301301
+ FullyQualifiedErrorId : CommandNotFoundException
302302
```
303303

304-
The [Invoke-Expression][26] cmdlet can execute code that causes parsing errors
304+
The [Invoke-Expression][27] cmdlet can execute code that causes parsing errors
305305
when using the call operator.
306306

307307
```powershell
@@ -343,6 +343,11 @@ Hello World!
343343

344344
For more about scriptblocks, see [about_Script_Blocks][21].
345345

346+
> [!IMPORTANT]
347+
> Using this operator with untrusted data is a security risk. Only use trusted
348+
> data with this operator. For more information, see
349+
> [Validate All Inputs][26].
350+
346351
### Cast operator `[ ]`
347352

348353
Converts or limits objects to the specified type. If the objects can't be
@@ -644,4 +649,5 @@ properties and methods of an object, use the Static parameter of the
644649
[22]: about_Split.md
645650
[23]: about_Type_Operators.md
646651
[24]: about_Variables.md
647-
[26]: xref:Microsoft.PowerShell.Utility.Invoke-Expression
652+
[26]: https://top10proactive.owasp.org/archive/2024/the-top-10/c3-validate-input-and-handle-exceptions/
653+
[27]: xref:Microsoft.PowerShell.Utility.Invoke-Expression

reference/5.1/Microsoft.PowerShell.Core/Invoke-Command.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
external help file: System.Management.Automation.dll-Help.xml
33
Locale: en-US
44
Module Name: Microsoft.PowerShell.Core
5-
ms.date: 01/18/2026
5+
ms.date: 03/24/2026
66
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/invoke-command?view=powershell-5.1&WT.mc_id=ps-gethelp
77
schema: 2.0.0
88
aliases:
@@ -706,6 +706,11 @@ passed by position from the array value supplied to **ArgumentList**. This is kn
706706
splatting. For more information about the behavior of **ArgumentList**, see
707707
[about_Splatting](about/about_Splatting.md#splatting-with-arrays).
708708

709+
> [!IMPORTANT]
710+
> Using this parameter with untrusted data is a security risk. Only use trusted data with this
711+
> parameter. For more information, see
712+
> [Validate All Inputs](https://top10proactive.owasp.org/archive/2024/the-top-10/c3-validate-input-and-handle-exceptions/).
713+
709714
```yaml
710715
Type: System.Object[]
711716
Parameter Sets: (All)
@@ -1002,6 +1007,11 @@ the values of parameters in the script.
10021007
When you use this parameter, PowerShell converts the contents of the specified script file to a
10031008
scriptblock, transmits the scriptblock to the remote computer, and runs it on the remote computer.
10041009

1010+
> [!IMPORTANT]
1011+
> Using this parameter with untrusted data is a security risk. Only use trusted data with this
1012+
> parameter. For more information, see
1013+
> [Validate All Inputs](https://top10proactive.owasp.org/archive/2024/the-top-10/c3-validate-input-and-handle-exceptions/).
1014+
10051015
```yaml
10061016
Type: System.String
10071017
Parameter Sets: FilePathRunspace, FilePathComputerName, FilePathUri, FilePathVMId, FilePathVMName, FilePathContainerId

reference/5.1/Microsoft.PowerShell.Management/Invoke-Item.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
external help file: Microsoft.PowerShell.Commands.Management.dll-Help.xml
33
Locale: en-US
44
Module Name: Microsoft.PowerShell.Management
5-
ms.date: 12/12/2022
5+
ms.date: 03/11/2026
66
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.management/invoke-item?view=powershell-5.1&WT.mc_id=ps-gethelp
77
schema: 2.0.0
88
aliases:
@@ -151,6 +151,11 @@ as escape sequences.
151151

152152
For more information, see [about_Quoting_Rules](../Microsoft.Powershell.Core/About/about_Quoting_Rules.md).
153153

154+
> [!IMPORTANT]
155+
> Using this parameter with untrusted data is a security risk. Only use trusted data with this
156+
> parameter. For more information, see
157+
> [Validate All Inputs](https://top10proactive.owasp.org/archive/2024/the-top-10/c3-validate-input-and-handle-exceptions/).
158+
154159
```yaml
155160
Type: System.String[]
156161
Parameter Sets: LiteralPath
@@ -166,7 +171,11 @@ Accept wildcard characters: False
166171
### -Path
167172

168173
Specifies the path to the selected item.
169-
Wildcard characters are permitted.
174+
175+
> [!IMPORTANT]
176+
> Using this parameter with untrusted data is a security risk. Only use trusted data with this
177+
> parameter. For more information, see
178+
> [Validate All Inputs](https://top10proactive.owasp.org/archive/2024/the-top-10/c3-validate-input-and-handle-exceptions/).
170179

171180
```yaml
172181
Type: System.String[]
@@ -236,7 +245,7 @@ Accept wildcard characters: False
236245
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable,
237246
-InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose,
238247
-WarningAction, and -WarningVariable. For more information, see
239-
[about_CommonParameters](../Microsoft.PowerShell.Core/About/about_CommonParameters.md).
248+
[about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216).
240249

241250
## INPUTS
242251

reference/5.1/Microsoft.PowerShell.Management/Show-EventLog.md

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,8 @@ Show-EventLog [[-ComputerName] <String>] [<CommonParameters>]
2424
The `Show-EventLog` cmdlet opens Event Viewer on the local computer and displays in it all of the
2525
classic event logs on the local computer or a remote computer.
2626

27-
To open Event Viewer on Windows Vista and later versions of the Windows operating system, the
28-
current user must be a member of the Administrators group on the local computer.
29-
30-
The cmdlets that contain the **EventLog** noun (the **EventLog** cmdlets) work only on classic event
31-
logs. To get events from logs that use the Windows Event Log technology in Windows Vista and later
32-
versions of the Windows operating system, use the `Get-WinEvent` cmdlet.
27+
The cmdlets that contain the **EventLog** noun work only on classic event logs. To get events from
28+
logs that use the Windows Event Log technology, use the `Get-WinEvent` cmdlet.
3329

3430
## EXAMPLES
3531

@@ -54,12 +50,13 @@ This command opens Event Viewer and displays in it the classic event logs on the
5450
### -ComputerName
5551

5652
Specifies a remote computer. `Show-EventLog` displays the event logs from the specified computer in
57-
Event Viewer on the local computer. The default is the local computer.
58-
59-
Type the NetBIOS name, an IP address, or a fully qualified domain name of a remote computer.
53+
Event Viewer on the local computer. The default is the local computer. When you use this parameter,
54+
the command runs `eventvwr.exe` and passes the value of this parameter.
6055

61-
This parameter does not rely on Windows PowerShell remoting. You can use the **ComputerName**
62-
parameter even if your computer is not configured to run remote commands.
56+
> [!IMPORTANT]
57+
> Using this parameter with untrusted data is a security risk. Only use trusted data with this
58+
> parameter. For more information, see
59+
> [Validate All Inputs](https://top10proactive.owasp.org/archive/2024/the-top-10/c3-validate-input-and-handle-exceptions/).
6360
6461
```yaml
6562
Type: System.String
@@ -77,26 +74,27 @@ Accept wildcard characters: False
7774
7875
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable,
7976
-InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose,
80-
-WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216).
77+
-WarningAction, and -WarningVariable. For more information, see
78+
[about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216).
8179
8280
## INPUTS
8381
8482
### None
8583
86-
You cannot pipe input to this cmdlet.
84+
You can't pipe input to this cmdlet.
8785
8886
## OUTPUTS
8987
9088
### None
9189
92-
This cmdlet does not generate any output.
90+
This cmdlet doesn't generate any output.
9391
9492
## NOTES
9593
9694
- The Windows PowerShell command prompt returns as soon as Event Viewer opens. You can work in the
9795
current session while Event Viewer is open.
9896
99-
Because this cmdlet requires a user interface, it does not work on Server Core installations of
97+
Because this cmdlet requires a user interface, it doesn't work on Server Core installations of
10098
Windows Server.
10199
102100
## RELATED LINKS

reference/5.1/Microsoft.PowerShell.Management/Start-Process.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
external help file: Microsoft.PowerShell.Commands.Management.dll-Help.xml
33
Locale: en-US
44
Module Name: Microsoft.PowerShell.Management
5-
ms.date: 11/01/2023
5+
ms.date: 03/11/2026
66
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.management/start-process?view=powershell-5.1&WT.mc_id=ps-gethelp
77
schema: 2.0.0
88
aliases:
@@ -203,6 +203,11 @@ program on the computer. This parameter is required.
203203

204204
If you specify only a filename, use the **WorkingDirectory** parameter to specify the path.
205205

206+
> [!IMPORTANT]
207+
> Using this parameter with untrusted data is a security risk. Only use trusted data with this
208+
> parameter. For more information, see
209+
> [Validate All Inputs](https://top10proactive.owasp.org/archive/2024/the-top-10/c3-validate-input-and-handle-exceptions/).
210+
206211
```yaml
207212
Type: System.String
208213
Parameter Sets: (All)
@@ -418,6 +423,11 @@ Specifies the location that the new process should start in. The default is the
418423
executable file or document being started. Wildcards aren't supported. The path must not contain
419424
characters that would be interpreted as wildcards.
420425

426+
> [!IMPORTANT]
427+
> Using this parameter with untrusted data is a security risk. Only use trusted data with this
428+
> parameter. For more information, see
429+
> [Validate All Inputs](https://top10proactive.owasp.org/archive/2024/the-top-10/c3-validate-input-and-handle-exceptions/).
430+
421431
```yaml
422432
Type: System.String
423433
Parameter Sets: (All)

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

Lines changed: 59 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
---
22
description: Describes arrays, which are data structures designed to store collections of items.
33
Locale: en-US
4-
ms.date: 01/18/2026
4+
ms.date: 03/24/2026
55
no-loc: [Count, Length, LongLength, Rank, ForEach, Clear, Default, First, Last, SkipUntil, Until, Split, Tuple]
6-
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_arrays?view=powershell-5.1&WT.mc_id=ps-gethelp
6+
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_arrays?view=powershell-7.4&WT.mc_id=ps-gethelp
77
schema: 2.0.0
88
title: about_Arrays
99
---
@@ -583,12 +583,67 @@ every item in the collection.
583583
Wednesday, June 20, 2018 9:21:57 AM
584584
```
585585

586+
> [!NOTE]
587+
> The `ForEach()` method wraps properties into a collection before enumeration.
588+
> Using `ForEach()` normally returns all items in both array. However, if you
589+
> want to access elements of the wrapped collection, you need to use two
590+
> indices.
591+
592+
Consider the following example where the object `$myObject` has a property with
593+
single value and a property containing an array of 11 integers.
594+
595+
```powershell
596+
$myObject = [pscustomobject]@{
597+
singleValue = 'Hello'
598+
arrayValue = @(0..10)
599+
}
600+
```
601+
602+
When you use the `ForEach()` method to access a property of the object, the
603+
property is wrapped in a collection.
604+
605+
```powershell
606+
PS> $myObject.ForEach('singleValue').GetType().Name
607+
Collection`1
608+
PS> $myObject.ForEach('singleValue')[0].GetType().Name
609+
String
610+
PS> $myObject.ForEach('singleValue') # Enumerate the collection object
611+
Hello
612+
```
613+
614+
To access the an element of the array, you need to use two indices.
615+
616+
```powershell
617+
PS> $myObject.ForEach('arrayValue').GetType().Name
618+
Collection`1
619+
# A single Collection item
620+
PS> $myObject.ForEach('arrayValue').Count
621+
1
622+
# First item in the collection is an array of 11 items
623+
PS> $myObject.ForEach('Value')[0].Count
624+
11
625+
# Access the first item in the array of 11 items
626+
PS> $myObject.ForEach('Value')[0][0]
627+
0
628+
```
629+
630+
This is different than using the `ForEach()` method using with a scriptblock to
631+
access the **Value** property of each object.
632+
633+
```powershell
634+
PS> $myObject.ForEach({$_.Value}).Count # An array of 11 items
635+
11
636+
```
637+
638+
Use the scriptblock syntax to avoid the wrapping behavior when you want to
639+
access complex property types, such as arrays or nested objects.
640+
586641
#### ForEach(string methodName)
587642

588643
#### ForEach(string methodName, object[] arguments)
589644

590-
Lastly, `ForEach()` methods can be used to execute a method on every item in
591-
the collection.
645+
You can use the `ForEach()` method to execute an object's method on every item
646+
in the collection.
592647

593648
```powershell
594649
("one", "two", "three").ForEach("ToUpper")
@@ -1124,5 +1179,3 @@ LastWriteTimeUtc Property datetime LastWriteTimeUtc {get;set;}
11241179
[13]: about_While.md
11251180
[14]: https://wikipedia.org/wiki/Row-_and_column-major_order
11261181

1127-
1128-

0 commit comments

Comments
 (0)