Skip to content

Commit 36127e5

Browse files
Merge pull request #12834 from MicrosoftDocs/main
Auto Publish – main to live - 2026-03-10 22:00 UTC
2 parents 4ab33dc + 7d25730 commit 36127e5

File tree

5 files changed

+124
-34
lines changed

5 files changed

+124
-34
lines changed

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

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
description: Explains how to add parameters to advanced functions.
33
Locale: en-US
4-
ms.date: 01/18/2026
4+
ms.date: 03/10/2026
55
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_functions_advanced_parameters?view=powershell-5.1&WT.mc_id=ps-gethelp
66
schema: 2.0.0
77
title: about_Functions_Advanced_Parameters
@@ -576,40 +576,36 @@ The `ValueFromRemainingArguments` argument indicates that the parameter accepts
576576
all the parameter's values in the command that aren't assigned to other
577577
parameters of the function.
578578

579-
There's a known issue for using collections with
580-
**ValueFromRemainingArguments** where the passed-in collection is treated as a
579+
Collections passed to **ValueFromRemainingArguments** are always treated as a
581580
single element.
582581

583-
The following example demonstrates this known issue. The **Remaining**
584-
parameter should contain **one** at **index 0** and **two** at **index 1**.
585-
Instead, both elements are combined into a single entity.
586-
587582
```powershell
588583
function Test-Remainder {
589584
param(
590585
[Parameter(Mandatory, Position=0)]
591586
[string]$Value,
592587
593-
[Parameter(Position=1, ValueFromRemainingArguments)]
588+
[Parameter(ValueFromRemainingArguments, Position=1)]
594589
[string[]]$Remaining
595590
)
596591
597-
"Found $($Remaining.Count) elements"
592+
"Value = $Value"
593+
"Found $($Remaining.Count) remaining values"
598594
599595
for ($i = 0; $i -lt $Remaining.Count; $i++) {
600596
"${i}: $($Remaining[$i])"
601597
}
602598
}
603-
Test-Remainder first one, two
604599
```
605600

606-
```Output
607-
Found 1 elements
608-
0: one two
609-
```
601+
```powershell
602+
PS> Test-Remainder first one two, three
610603
611-
> [!NOTE]
612-
> This issue is resolved in PowerShell 6.2.
604+
Value = first
605+
Found 2 remaining values
606+
0: one
607+
1: two three
608+
```
613609

614610
#### HelpMessage argument
615611

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

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
description: Explains how to add parameters to advanced functions.
33
Locale: en-US
4-
ms.date: 01/18/2026
4+
ms.date: 03/10/2026
55
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_functions_advanced_parameters?view=powershell-7.4&WT.mc_id=ps-gethelp
66
schema: 2.0.0
77
title: about_Functions_Advanced_Parameters
@@ -581,23 +581,54 @@ function Test-Remainder {
581581
[Parameter(Mandatory, Position=0)]
582582
[string]$Value,
583583
584-
[Parameter(Position=1, ValueFromRemainingArguments)]
584+
[Parameter(ValueFromRemainingArguments, Position=1)]
585585
[string[]]$Remaining
586586
)
587587
588-
"Found $($Remaining.Count) elements"
588+
"Value = $Value"
589+
"Found $($Remaining.Count) remaining values"
589590
590591
for ($i = 0; $i -lt $Remaining.Count; $i++) {
591592
"${i}: $($Remaining[$i])"
592593
}
593594
}
594-
Test-Remainder first one, two
595595
```
596596

597-
```Output
598-
Found 2 elements
597+
```powershell
598+
PS> Test-Remainder first one two three
599+
600+
Value = first
601+
Found 3 remaining values
599602
0: one
600603
1: two
604+
2: three
605+
```
606+
607+
Beginning in PowerShell 6.2, collections are handled differently when passed to
608+
**ValueFromRemainingArguments**. If you only pass a collection, then each value
609+
in the collection is treated as a separate item.
610+
611+
```powershell
612+
PS> Test-Remainder first one, two, three
613+
614+
Value = first
615+
Found 3 remaining values
616+
0: one
617+
1: two
618+
2: three
619+
```
620+
621+
When you pass multiple values where at least one isn't a collection, the
622+
collection is treated as a single item.
623+
624+
```powershell
625+
PS> Test-Remainder first one, two three four
626+
627+
Value = first
628+
Found 3 remaining values
629+
0: one two
630+
1: three
631+
2: four
601632
```
602633

603634
#### HelpMessage argument

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

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
description: Explains how to add parameters to advanced functions.
33
Locale: en-US
4-
ms.date: 01/18/2026
4+
ms.date: 03/10/2026
55
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_functions_advanced_parameters?view=powershell-7.5&WT.mc_id=ps-gethelp
66
schema: 2.0.0
77
title: about_Functions_Advanced_Parameters
@@ -581,23 +581,54 @@ function Test-Remainder {
581581
[Parameter(Mandatory, Position=0)]
582582
[string]$Value,
583583
584-
[Parameter(Position=1, ValueFromRemainingArguments)]
584+
[Parameter(ValueFromRemainingArguments, Position=1)]
585585
[string[]]$Remaining
586586
)
587587
588-
"Found $($Remaining.Count) elements"
588+
"Value = $Value"
589+
"Found $($Remaining.Count) remaining values"
589590
590591
for ($i = 0; $i -lt $Remaining.Count; $i++) {
591592
"${i}: $($Remaining[$i])"
592593
}
593594
}
594-
Test-Remainder first one, two
595595
```
596596

597-
```Output
598-
Found 2 elements
597+
```powershell
598+
PS> Test-Remainder first one two three
599+
600+
Value = first
601+
Found 3 remaining values
599602
0: one
600603
1: two
604+
2: three
605+
```
606+
607+
Beginning in PowerShell 6.2, collections are handled differently when passed to
608+
**ValueFromRemainingArguments**. If you only pass a collection, then each value
609+
in the collection is treated as a separate item.
610+
611+
```powershell
612+
PS> Test-Remainder first one, two, three
613+
614+
Value = first
615+
Found 3 remaining values
616+
0: one
617+
1: two
618+
2: three
619+
```
620+
621+
When you pass multiple values where at least one isn't a collection, the
622+
collection is treated as a single item.
623+
624+
```powershell
625+
PS> Test-Remainder first one, two three four
626+
627+
Value = first
628+
Found 3 remaining values
629+
0: one two
630+
1: three
631+
2: four
601632
```
602633

603634
#### HelpMessage argument

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

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
description: Explains how to add parameters to advanced functions.
33
Locale: en-US
4-
ms.date: 01/18/2026
4+
ms.date: 03/10/2026
55
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_functions_advanced_parameters?view=powershell-7.6&WT.mc_id=ps-gethelp
66
schema: 2.0.0
77
title: about_Functions_Advanced_Parameters
@@ -581,23 +581,54 @@ function Test-Remainder {
581581
[Parameter(Mandatory, Position=0)]
582582
[string]$Value,
583583
584-
[Parameter(Position=1, ValueFromRemainingArguments)]
584+
[Parameter(ValueFromRemainingArguments, Position=1)]
585585
[string[]]$Remaining
586586
)
587587
588-
"Found $($Remaining.Count) elements"
588+
"Value = $Value"
589+
"Found $($Remaining.Count) remaining values"
589590
590591
for ($i = 0; $i -lt $Remaining.Count; $i++) {
591592
"${i}: $($Remaining[$i])"
592593
}
593594
}
594-
Test-Remainder first one, two
595595
```
596596

597-
```Output
598-
Found 2 elements
597+
```powershell
598+
PS> Test-Remainder first one two three
599+
600+
Value = first
601+
Found 3 remaining values
599602
0: one
600603
1: two
604+
2: three
605+
```
606+
607+
Beginning in PowerShell 6.2, collections are handled differently when passed to
608+
**ValueFromRemainingArguments**. If you only pass a collection, then each value
609+
in the collection is treated as a separate item.
610+
611+
```powershell
612+
PS> Test-Remainder first one, two, three
613+
614+
Value = first
615+
Found 3 remaining values
616+
0: one
617+
1: two
618+
2: three
619+
```
620+
621+
When you pass multiple values where at least one isn't a collection, the
622+
collection is treated as a single item.
623+
624+
```powershell
625+
PS> Test-Remainder first one, two three four
626+
627+
Value = first
628+
Found 3 remaining values
629+
0: one two
630+
1: three
631+
2: four
601632
```
602633

603634
#### HelpMessage argument

reference/index.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ metadata:
1111
author: sdwheeler
1212
ms.author: sewhee
1313
ms.date: 03/18/2025
14+
no-loc: [Community, Discord, Slack, Spiceworks, "Stack Overflow" ]
1415

1516
# highlightedContent section (optional)
1617
# Maximum of 8 items

0 commit comments

Comments
 (0)