Skip to content

Commit

Permalink
Add note about passing array arguments (MicrosoftDocs#8864)
Browse files Browse the repository at this point in the history
  • Loading branch information
sdwheeler authored May 25, 2022
1 parent 960980e commit 7598990
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
description: Explains how to use the `powershell.exe` command-line interface. Displays the command-line parameters and describes the syntax.
Locale: en-US
ms.date: 10/05/2020
ms.date: 05/25/2022
no-no-loc: [-Command, -ConfigurationName , -EncodedCommand, -ExecutionPolicy, -File, -Help, -InputFormat, -Mta, -NoExit, -NoLogo, -NonInteractive, -NoProfile, -OutputFormat, -PSConsoleFile, -Sta, -Version, -WindowStyle]
online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.core/about/about_powershell_exe?view=powershell-5.1&WT.mc_id=ps-gethelp
schema: 2.0.0
Expand Down Expand Up @@ -157,6 +157,13 @@ It is not possible to pass an explicit boolean value for a switch parameter
when running a script in this way. This limitation was removed in PowerShell 6
(`pwsh.exe`).

> [!NOTE]
> The **File** parameter cannot support scripts using a parameter that expects
> an array of argument values. This, unfortunately, is a limitation of how a
> native command gets argument values. When you call a native executable (such
> as `powershell` or `pwsh`), it does not know what to do with an array, so
> it's passed as a string.
#### -ExecutionPolicy \<ExecutionPolicy\>

Sets the default execution policy for the current session and saves it in the
Expand Down
9 changes: 8 additions & 1 deletion reference/7.0/Microsoft.PowerShell.Core/About/about_Pwsh.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
description: Explains how to use the `pwsh` command-line interface. Displays the command-line parameters and describes the syntax.
Locale: en-US
ms.date: 03/07/2022
ms.date: 05/25/2022
no-loc: [-File, -f, -Command, -c, -ConfigurationName, -config, -CustomPipeName, -EncodedCommand, -e, -ec, -ExecutionPolicy, -ex, -ep, -InputFormat, -inp, -if, -Interactive, -i, -Login, -l, -MTA, -NoExit, -noe, -NoLogo, -nol, -NonInteractive, -noni, -NoProfile, -nop, -OutputFormat, -o, -of, -SettingsFile, -settings, -SSHServerMode, -sshs, -STA, -Version, -v, -WindowStyle, -w, -WorkingDirectory, -wd, -Help]
online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.core/about/about_pwsh?view=powershell-7&WT.mc_id=ps-gethelp
schema: 2.0.0
Expand Down Expand Up @@ -90,6 +90,13 @@ execution directory: `pwsh -File %~dp0test.ps1 -TestParam %windir%`. If you
instead used `.\test.ps1`, PowerShell would throw an error because it cannot
find the literal path `.\test.ps1`

> [!NOTE]
> The **File** parameter cannot support scripts using a parameter that expects
> an array of argument values. This, unfortunately, is a limitation of how a
> native command gets argument values. When you call a native executable (such
> as `powershell` or `pwsh`), it does not know what to do with an array, so
> it's passed as a string.
When the script file terminates with an `exit` command, the process exit code
is set to the numeric argument used with the `exit` command. With normal
termination, the exit code is always `0`.
Expand Down
9 changes: 8 additions & 1 deletion reference/7.2/Microsoft.PowerShell.Core/About/about_Pwsh.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
description: Explains how to use the `pwsh` command-line interface. Displays the command-line parameters and describes the syntax.
Locale: en-US
ms.date: 03/07/2022
ms.date: 05/25/2022
no-loc: [-File, -f, -Command, -c, -ConfigurationName, -config, -CustomPipeName, -EncodedCommand, -e, -ec, -ExecutionPolicy, -ex, -ep, -InputFormat, -inp, -if, -Interactive, -i, -Login, -l, -MTA, -NoExit, -noe, -NoLogo, -nol, -NonInteractive, -noni, -NoProfile, -nop, -OutputFormat, -o, -of, -SettingsFile, -settings, -SSHServerMode, -sshs, -STA, -Version, -v, -WindowStyle, -w, -WorkingDirectory, -wd, -Help]
online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.core/about/about_pwsh?view=powershell-7.2&WT.mc_id=ps-gethelp
schema: 2.0.0
Expand Down Expand Up @@ -90,6 +90,13 @@ execution directory: `pwsh -File %~dp0test.ps1 -TestParam %windir%`. If you
instead used `.\test.ps1`, PowerShell would throw an error because it cannot
find the literal path `.\test.ps1`

> [!NOTE]
> The **File** parameter cannot support scripts using a parameter that expects
> an array of argument values. This, unfortunately, is a limitation of how a
> native command gets argument values. When you call a native executable (such
> as `powershell` or `pwsh`), it does not know what to do with an array, so
> it's passed as a string.
When the script file terminates with an `exit` command, the process exit code
is set to the numeric argument used with the `exit` command. With normal
termination, the exit code is always `0`.
Expand Down
9 changes: 8 additions & 1 deletion reference/7.3/Microsoft.PowerShell.Core/About/about_Pwsh.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
description: Explains how to use the `pwsh` command-line interface. Displays the command-line parameters and describes the syntax.
Locale: en-US
ms.date: 03/07/2022
ms.date: 05/25/2022
no-loc: [-File, -f, -Command, -c, -ConfigurationName, -config, -CustomPipeName, -EncodedCommand, -e, -ec, -ExecutionPolicy, -ex, -ep, -InputFormat, -inp, -if, -Interactive, -i, -Login, -l, -MTA, -NoExit, -noe, -NoLogo, -nol, -NonInteractive, -noni, -NoProfile, -nop, -OutputFormat, -o, -of, -SettingsFile, -settings, -SSHServerMode, -sshs, -STA, -Version, -v, -WindowStyle, -w, -WorkingDirectory, -wd, -Help]
online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.core/about/about_pwsh?view=powershell-7.3&WT.mc_id=ps-gethelp
schema: 2.0.0
Expand Down Expand Up @@ -90,6 +90,13 @@ execution directory: `pwsh -File %~dp0test.ps1 -TestParam %windir%`. If you
instead used `.\test.ps1`, PowerShell would throw an error because it cannot
find the literal path `.\test.ps1`

> [!NOTE]
> The **File** parameter cannot support scripts using a parameter that expects
> an array of argument values. This, unfortunately, is a limitation of how a
> native command gets argument values. When you call a native executable (such
> as `powershell` or `pwsh`), it does not know what to do with an array, so
> it's passed as a string.
When the script file terminates with an `exit` command, the process exit code
is set to the numeric argument used with the `exit` command. With normal
termination, the exit code is always `0`.
Expand Down

0 comments on commit 7598990

Please sign in to comment.