diff --git a/reference/5.1/Microsoft.PowerShell.Core/About/about_PSItem.md b/reference/5.1/Microsoft.PowerShell.Core/About/about_PSItem.md index 9281474c5c11..d320d16d98c1 100644 --- a/reference/5.1/Microsoft.PowerShell.Core/About/about_PSItem.md +++ b/reference/5.1/Microsoft.PowerShell.Core/About/about_PSItem.md @@ -1,7 +1,7 @@ --- description: The automatic variable that contains the current object in the pipeline object. Locale: en-US -ms.date: 12/07/2022 +ms.date: 01/31/2025 online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_psitem?view=powershell-5.1&WT.mc_id=ps-gethelp schema: 2.0.0 title: about_PSItem @@ -15,7 +15,7 @@ The automatic variable that contains the current object in the pipeline object. ## Long description PowerShell includes the `$PSItem` variable and its alias, `$_`, as -[automatic variables][01] in scriptblocks that process the current object, such +[automatic variables][03] in scriptblocks that process the current object, such as in the pipeline. This article uses `$PSItem` in the examples, but `$PSItem` can be replaced with `$_` in every example. @@ -24,23 +24,24 @@ a pipeline. There are a few common use cases for `$PSItem`: -- in the scriptblock for the **Process** parameter of the +- In the scriptblock for the **Process** parameter of the `ForEach-Object`cmdlet -- in the scriptblock for the **FilterScript** parameter of the `Where-Object` +- In the scriptblock for the **FilterScript** parameter of the `Where-Object` cmdlet -- in the intrinsic methods **ForEach** and **Where** +- In the intrinsic methods **ForEach** and **Where** - with delay-bind scriptblock parameters -- in a `switch` statement's conditional values and associated scriptblocks -- in the `process` block of a function -- in a `filter` definition -- in the scriptblock of the **ValidateScript** attribute +- In a `switch` statement's conditional values and associated scriptblocks +- In the `process` block of a function +- In a `filter` definition +- In the scriptblock of the **ValidateScript** attribute +- In the scriptblock of a `catch` statement The rest of this article includes examples of using `$PSItem` for these use cases. ## ForEach-Object Process -The [ForEach-Object][02] cmdlet is designed to operate on objects in the +The [ForEach-Object][15] cmdlet is designed to operate on objects in the pipeline, executing the **Process** parameter's scriptblock once for every object in the pipeline. @@ -75,7 +76,7 @@ Result is: 2 3 4 ## Where-Object FilterScript -The [Where-Object][03] cmdlet is designed to filter objects in the pipeline. +The [Where-Object][16] cmdlet is designed to filter objects in the pipeline. You can use `$PSItem` in the scriptblock of the **FilterScript** parameter, which executes once for each input object in the pipeline. @@ -94,7 +95,7 @@ list. ## ForEach and Where methods -Both the [ForEach][04] and [Where][05] intrinsic methods for arrays take a +Both the [ForEach][01] and [Where][02] intrinsic methods for arrays take a scriptblock as an input parameter. You can use the `$PSItem` in those scriptblocks to access the current object. @@ -111,7 +112,7 @@ current object. Then the scriptblock of the **Where** method returns only `B`. ## Delay-bind scriptblock parameters -[Delay-bind scriptblocks][06] let you use `$PSItem` to define parameters for a +[Delay-bind scriptblocks][12] let you use `$PSItem` to define parameters for a pipelined cmdlet before executing it. ```powershell @@ -120,7 +121,7 @@ dir config.log | Rename-Item -NewName { "old_$($_.Name)" } ## Switch statement scriptblocks -In [switch statements][07], you can use `$PSItem` in both action scriptblocks +In [switch statements][13], you can use `$PSItem` in both action scriptblocks and statement condition scriptblocks. ```powershell @@ -147,7 +148,7 @@ the current object is odd. ## Function process blocks -When you define a [function][08], you can use `$PSItem` in the `process` block +When you define a [function][09], you can use `$PSItem` in the `process` block definition but not in the `begin` or `end` block definitions. If you reference `$PSItem` in the `begin` or `end` blocks, the value is `$null` because those blocks don't operate on each object in the pipeline. @@ -171,10 +172,10 @@ function Add-One { ``` > [!TIP] -> While you can use `$PSItem` in [advanced functions][09], there's little +> While you can use `$PSItem` in [advanced functions][08], there's little > reason to do so. If you intend to receive input from the pipeline, > it's best to define parameters with one of the `ValueFromPipeline*` arguments -> for the [Parameter][10] attribute. +> for the [Parameter][06] attribute. Using the **Parameter** attribute and cmdlet binding for advanced functions makes the implementation more explicit and predictable than processing the @@ -275,7 +276,7 @@ VERBOSE: Input object 3 is: ## Filter definitions -You can use `$PSItem` in the statement list of a [filter][11]'s definition. +You can use `$PSItem` in the statement list of a [filter][10]'s definition. When you use `$PSItem` in a `filter` definition, the value is the current object if the filter is called in the pipeline and otherwise `$null`. @@ -297,7 +298,7 @@ is an even number and `$false` if it isn't. ## The ValidateScript attribute scriptblock -You can use `$PSItem` in the scriptblock of a [ValidateScript][15] attribute. +You can use `$PSItem` in the scriptblock of a [ValidateScript][07] attribute. When used with **ValidateScript**, `$PSItem` is the value of the current object being validated. When the variable or parameter value is an array, the scriptblock is called once for each object in the array with `$PSItem` as the @@ -353,29 +354,56 @@ value isn't even. The `Add-EvenNumber` function adds the valid input numbers and returns the total. +## The catch statement scriptblock + +Within a `catch` block, the current error can be accessed using `$PSItem`. The +object is of type **ErrorRecord**. + +```powershell +try { NonsenseString } +catch { + Write-Host "An error occurred:" + Write-Host $_ +} +``` + +Running this script returns the following result: + +```Output +An Error occurred: +The term 'NonsenseString' is not recognized as the name of a cmdlet, function, +script file, or operable program. Check the spelling of the name, or if a path +was included, verify that the path is correct and try again. +``` + +For more examples, see the _Accessing exception information_ section in +[about_Try_Catch_Finally][14]. + ## See also -- [about_Arrays][04] -- [about_Automatic_Variables][01] -- [about_Comparison_Operators][12] -- [about_Functions][08] -- [about_Script_Blocks][14] -- [about_Switch][07] -- [ForEach-Object][02] -- [Where-Object][03] +- [about_Arrays][01] +- [about_Automatic_Variables][03] +- [about_Comparison_Operators][04] +- [about_Functions][09] +- [about_Script_Blocks][11] +- [about_Switch][13] +- [ForEach-Object][15] +- [Where-Object][16] -[01]: about_Automatic_Variables.md -[02]: xref:Microsoft.PowerShell.Core.ForEach-Object -[03]: xref:Microsoft.PowerShell.Core.Where-Object -[04]: about_Arrays.md#foreach -[05]: about_Arrays.md#where -[06]: about_Script_Blocks.md#using-delay-bind-script-blocks-with-parameters -[07]: about_Switch.md -[08]: about_Functions.md -[09]: about_Functions_Advanced.md -[10]: about_Functions_Advanced_Parameters.md#parameter-attribute -[11]: about_Functions.md#filters -[12]: about_Comparison_Operators.md#replacement-operator -[14]: about_Script_Blocks.md -[15]: about_Functions_Advanced_Parameters.md#validatescript-validation-attribute +[01]: about_Arrays.md#foreach +[02]: about_Arrays.md#where +[03]: about_Automatic_Variables.md +[04]: about_Comparison_Operators.md#replacement-operator + +[06]: about_Functions_Advanced_Parameters.md#parameter-attribute +[07]: about_Functions_Advanced_Parameters.md#validatescript-validation-attribute +[08]: about_Functions_Advanced.md +[09]: about_Functions.md +[10]: about_Functions.md#filters +[11]: about_Script_Blocks.md +[12]: about_Script_Blocks.md#using-delay-bind-script-blocks-with-parameters +[13]: about_Switch.md +[14]: about_Try_Catch_Finally.md#accessing-exception-information +[15]: xref:Microsoft.PowerShell.Core.ForEach-Object +[16]: xref:Microsoft.PowerShell.Core.Where-Object diff --git a/reference/7.4/Microsoft.PowerShell.Core/About/about_PSItem.md b/reference/7.4/Microsoft.PowerShell.Core/About/about_PSItem.md index 68a66e3a62cf..c9b1bfbb6354 100644 --- a/reference/7.4/Microsoft.PowerShell.Core/About/about_PSItem.md +++ b/reference/7.4/Microsoft.PowerShell.Core/About/about_PSItem.md @@ -1,7 +1,7 @@ --- description: The automatic variable that contains the current object in the pipeline object. Locale: en-US -ms.date: 12/07/2022 +ms.date: 01/31/2025 online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_psitem?view=powershell-7.4&WT.mc_id=ps-gethelp schema: 2.0.0 title: about_PSItem @@ -15,7 +15,7 @@ The automatic variable that contains the current object in the pipeline object. ## Long description PowerShell includes the `$PSItem` variable and its alias, `$_`, as -[automatic variables][01] in scriptblocks that process the current object, such +[automatic variables][03] in scriptblocks that process the current object, such as in the pipeline. This article uses `$PSItem` in the examples, but `$PSItem` can be replaced with `$_` in every example. @@ -24,24 +24,25 @@ a pipeline. There are a few common use cases for `$PSItem`: -- in the scriptblock for the **Process** parameter of the +- In the scriptblock for the **Process** parameter of the `ForEach-Object`cmdlet -- in the scriptblock for the **FilterScript** parameter of the `Where-Object` +- In the scriptblock for the **FilterScript** parameter of the `Where-Object` cmdlet -- in the intrinsic methods **ForEach** and **Where** +- In the intrinsic methods **ForEach** and **Where** - with delay-bind scriptblock parameters -- in a `switch` statement's conditional values and associated scriptblocks -- in the `process` block of a function -- in a `filter` definition -- in the scriptblock of the **ValidateScript** attribute -- in the substitution operand scriptblock of the `-replace` operator +- In a `switch` statement's conditional values and associated scriptblocks +- In the `process` block of a function +- In a `filter` definition +- In the scriptblock of the **ValidateScript** attribute +- In the scriptblock of a `catch` statement +- In the substitution operand scriptblock of the `-replace` operator The rest of this article includes examples of using `$PSItem` for these use cases. ## ForEach-Object Process -The [ForEach-Object][02] cmdlet is designed to operate on objects in the +The [ForEach-Object][15] cmdlet is designed to operate on objects in the pipeline, executing the **Process** parameter's scriptblock once for every object in the pipeline. @@ -76,7 +77,7 @@ Result is: 2 3 4 ## Where-Object FilterScript -The [Where-Object][03] cmdlet is designed to filter objects in the pipeline. +The [Where-Object][16] cmdlet is designed to filter objects in the pipeline. You can use `$PSItem` in the scriptblock of the **FilterScript** parameter, which executes once for each input object in the pipeline. @@ -95,7 +96,7 @@ list. ## ForEach and Where methods -Both the [ForEach][04] and [Where][05] intrinsic methods for arrays take a +Both the [ForEach][01] and [Where][02] intrinsic methods for arrays take a scriptblock as an input parameter. You can use the `$PSItem` in those scriptblocks to access the current object. @@ -112,7 +113,7 @@ current object. Then the scriptblock of the **Where** method returns only `B`. ## Delay-bind scriptblock parameters -[Delay-bind scriptblocks][06] let you use `$PSItem` to define parameters for a +[Delay-bind scriptblocks][12] let you use `$PSItem` to define parameters for a pipelined cmdlet before executing it. ```powershell @@ -121,7 +122,7 @@ dir config.log | Rename-Item -NewName { "old_$($_.Name)" } ## Switch statement scriptblocks -In [switch statements][07], you can use `$PSItem` in both action scriptblocks +In [switch statements][13], you can use `$PSItem` in both action scriptblocks and statement condition scriptblocks. ```powershell @@ -148,7 +149,7 @@ the current object is odd. ## Function process blocks -When you define a [function][08], you can use `$PSItem` in the `process` block +When you define a [function][09], you can use `$PSItem` in the `process` block definition but not in the `begin` or `end` block definitions. If you reference `$PSItem` in the `begin` or `end` blocks, the value is `$null` because those blocks don't operate on each object in the pipeline. @@ -172,10 +173,10 @@ function Add-One { ``` > [!TIP] -> While you can use `$PSItem` in [advanced functions][09], there's little +> While you can use `$PSItem` in [advanced functions][08], there's little > reason to do so. If you intend to receive input from the pipeline, > it's best to define parameters with one of the `ValueFromPipeline*` arguments -> for the [Parameter][10] attribute. +> for the [Parameter][06] attribute. Using the **Parameter** attribute and cmdlet binding for advanced functions makes the implementation more explicit and predictable than processing the @@ -276,7 +277,7 @@ VERBOSE: Input object 3 is: ## Filter definitions -You can use `$PSItem` in the statement list of a [filter][11]'s definition. +You can use `$PSItem` in the statement list of a [filter][10]'s definition. When you use `$PSItem` in a `filter` definition, the value is the current object if the filter is called in the pipeline and otherwise `$null`. @@ -298,7 +299,7 @@ is an even number and `$false` if it isn't. ## The ValidateScript attribute scriptblock -You can use `$PSItem` in the scriptblock of a [ValidateScript][15] attribute. +You can use `$PSItem` in the scriptblock of a [ValidateScript][07] attribute. When used with **ValidateScript**, `$PSItem` is the value of the current object being validated. When the variable or parameter value is an array, the scriptblock is called once for each object in the array with `$PSItem` as the @@ -352,10 +353,35 @@ value isn't even. The `Add-EvenNumber` function adds the valid input numbers and returns the total. +## The catch statement scriptblock + +Within a `catch` block, the current error can be accessed using `$PSItem`. The +object is of type **ErrorRecord**. + +```powershell +try { NonsenseString } +catch { + Write-Host "An error occurred:" + Write-Host $_ +} +``` + +Running this script returns the following result: + +```Output +An Error occurred: +The term 'NonsenseString' is not recognized as the name of a cmdlet, function, +script file, or operable program. Check the spelling of the name, or if a path +was included, verify that the path is correct and try again. +``` + +For more examples, see the _Accessing exception information_ section in +[about_Try_Catch_Finally][14]. + ## The -replace operator's substitution scriptblock -Starting in PowerShell 6, you can use `$PSItem` when calling the [replace][12] -operator and defining a [substitution scriptblock][13]. When you do, the value +Starting in PowerShell 6, you can use `$PSItem` when calling the [replace][04] +operator and defining a [substitution scriptblock][05]. When you do, the value of `$PSItem` is the value of the current match. ```powershell @@ -373,28 +399,29 @@ with the default format for the current culture by casting the value to ## See also -- [about_Arrays][04] -- [about_Automatic_Variables][01] -- [about_Comparison_Operators][12] -- [about_Functions][08] -- [about_Script_Blocks][14] -- [about_Switch][07] -- [ForEach-Object][02] -- [Where-Object][03] +- [about_Arrays][01] +- [about_Automatic_Variables][03] +- [about_Comparison_Operators][04] +- [about_Functions][09] +- [about_Script_Blocks][11] +- [about_Switch][13] +- [ForEach-Object][15] +- [Where-Object][16] -[01]: about_Automatic_Variables.md -[02]: xref:Microsoft.PowerShell.Core.ForEach-Object -[03]: xref:Microsoft.PowerShell.Core.Where-Object -[04]: about_Arrays.md#foreach -[05]: about_Arrays.md#where -[06]: about_Script_Blocks.md#using-delay-bind-script-blocks-with-parameters -[07]: about_Switch.md -[08]: about_Functions.md -[09]: about_Functions_Advanced.md -[10]: about_Functions_Advanced_Parameters.md#parameter-attribute -[11]: about_Functions.md#filters -[12]: about_Comparison_Operators.md#replacement-operator -[13]: about_Comparison_Operators.md#replacement-with-a-script-block -[14]: about_Script_Blocks.md -[15]: about_Functions_Advanced_Parameters.md#validatescript-validation-attribute +[01]: about_Arrays.md#foreach +[02]: about_Arrays.md#where +[03]: about_Automatic_Variables.md +[04]: about_Comparison_Operators.md#replacement-operator +[05]: about_Comparison_Operators.md#replacement-with-a-script-block +[06]: about_Functions_Advanced_Parameters.md#parameter-attribute +[07]: about_Functions_Advanced_Parameters.md#validatescript-validation-attribute +[08]: about_Functions_Advanced.md +[09]: about_Functions.md +[10]: about_Functions.md#filters +[11]: about_Script_Blocks.md +[12]: about_Script_Blocks.md#using-delay-bind-script-blocks-with-parameters +[13]: about_Switch.md +[14]: about_Try_Catch_Finally.md#accessing-exception-information +[15]: xref:Microsoft.PowerShell.Core.ForEach-Object +[16]: xref:Microsoft.PowerShell.Core.Where-Object diff --git a/reference/7.5/Microsoft.PowerShell.Core/About/about_PSItem.md b/reference/7.5/Microsoft.PowerShell.Core/About/about_PSItem.md index 27280fbf1de5..4c43f7e3b8f7 100644 --- a/reference/7.5/Microsoft.PowerShell.Core/About/about_PSItem.md +++ b/reference/7.5/Microsoft.PowerShell.Core/About/about_PSItem.md @@ -1,7 +1,7 @@ --- description: The automatic variable that contains the current object in the pipeline object. Locale: en-US -ms.date: 12/07/2022 +ms.date: 01/31/2025 online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_psitem?view=powershell-7.5&WT.mc_id=ps-gethelp schema: 2.0.0 title: about_PSItem @@ -15,7 +15,7 @@ The automatic variable that contains the current object in the pipeline object. ## Long description PowerShell includes the `$PSItem` variable and its alias, `$_`, as -[automatic variables][01] in scriptblocks that process the current object, such +[automatic variables][03] in scriptblocks that process the current object, such as in the pipeline. This article uses `$PSItem` in the examples, but `$PSItem` can be replaced with `$_` in every example. @@ -24,24 +24,25 @@ a pipeline. There are a few common use cases for `$PSItem`: -- in the scriptblock for the **Process** parameter of the +- In the scriptblock for the **Process** parameter of the `ForEach-Object`cmdlet -- in the scriptblock for the **FilterScript** parameter of the `Where-Object` +- In the scriptblock for the **FilterScript** parameter of the `Where-Object` cmdlet -- in the intrinsic methods **ForEach** and **Where** +- In the intrinsic methods **ForEach** and **Where** - with delay-bind scriptblock parameters -- in a `switch` statement's conditional values and associated scriptblocks -- in the `process` block of a function -- in a `filter` definition -- in the scriptblock of the **ValidateScript** attribute -- in the substitution operand scriptblock of the `-replace` operator +- In a `switch` statement's conditional values and associated scriptblocks +- In the `process` block of a function +- In a `filter` definition +- In the scriptblock of the **ValidateScript** attribute +- In the scriptblock of a `catch` statement +- In the substitution operand scriptblock of the `-replace` operator The rest of this article includes examples of using `$PSItem` for these use cases. ## ForEach-Object Process -The [ForEach-Object][02] cmdlet is designed to operate on objects in the +The [ForEach-Object][15] cmdlet is designed to operate on objects in the pipeline, executing the **Process** parameter's scriptblock once for every object in the pipeline. @@ -76,7 +77,7 @@ Result is: 2 3 4 ## Where-Object FilterScript -The [Where-Object][03] cmdlet is designed to filter objects in the pipeline. +The [Where-Object][16] cmdlet is designed to filter objects in the pipeline. You can use `$PSItem` in the scriptblock of the **FilterScript** parameter, which executes once for each input object in the pipeline. @@ -95,7 +96,7 @@ list. ## ForEach and Where methods -Both the [ForEach][04] and [Where][05] intrinsic methods for arrays take a +Both the [ForEach][01] and [Where][02] intrinsic methods for arrays take a scriptblock as an input parameter. You can use the `$PSItem` in those scriptblocks to access the current object. @@ -112,7 +113,7 @@ current object. Then the scriptblock of the **Where** method returns only `B`. ## Delay-bind scriptblock parameters -[Delay-bind scriptblocks][06] let you use `$PSItem` to define parameters for a +[Delay-bind scriptblocks][12] let you use `$PSItem` to define parameters for a pipelined cmdlet before executing it. ```powershell @@ -121,7 +122,7 @@ dir config.log | Rename-Item -NewName { "old_$($_.Name)" } ## Switch statement scriptblocks -In [switch statements][07], you can use `$PSItem` in both action scriptblocks +In [switch statements][13], you can use `$PSItem` in both action scriptblocks and statement condition scriptblocks. ```powershell @@ -148,7 +149,7 @@ the current object is odd. ## Function process blocks -When you define a [function][08], you can use `$PSItem` in the `process` block +When you define a [function][09], you can use `$PSItem` in the `process` block definition but not in the `begin` or `end` block definitions. If you reference `$PSItem` in the `begin` or `end` blocks, the value is `$null` because those blocks don't operate on each object in the pipeline. @@ -172,10 +173,10 @@ function Add-One { ``` > [!TIP] -> While you can use `$PSItem` in [advanced functions][09], there's little +> While you can use `$PSItem` in [advanced functions][08], there's little > reason to do so. If you intend to receive input from the pipeline, > it's best to define parameters with one of the `ValueFromPipeline*` arguments -> for the [Parameter][10] attribute. +> for the [Parameter][06] attribute. Using the **Parameter** attribute and cmdlet binding for advanced functions makes the implementation more explicit and predictable than processing the @@ -276,7 +277,7 @@ VERBOSE: Input object 3 is: ## Filter definitions -You can use `$PSItem` in the statement list of a [filter][11]'s definition. +You can use `$PSItem` in the statement list of a [filter][10]'s definition. When you use `$PSItem` in a `filter` definition, the value is the current object if the filter is called in the pipeline and otherwise `$null`. @@ -298,7 +299,7 @@ is an even number and `$false` if it isn't. ## The ValidateScript attribute scriptblock -You can use `$PSItem` in the scriptblock of a [ValidateScript][15] attribute. +You can use `$PSItem` in the scriptblock of a [ValidateScript][07] attribute. When used with **ValidateScript**, `$PSItem` is the value of the current object being validated. When the variable or parameter value is an array, the scriptblock is called once for each object in the array with `$PSItem` as the @@ -352,10 +353,35 @@ value isn't even. The `Add-EvenNumber` function adds the valid input numbers and returns the total. +## The catch statement scriptblock + +Within a `catch` block, the current error can be accessed using `$PSItem`. The +object is of type **ErrorRecord**. + +```powershell +try { NonsenseString } +catch { + Write-Host "An error occurred:" + Write-Host $_ +} +``` + +Running this script returns the following result: + +```Output +An Error occurred: +The term 'NonsenseString' is not recognized as the name of a cmdlet, function, +script file, or operable program. Check the spelling of the name, or if a path +was included, verify that the path is correct and try again. +``` + +For more examples, see the _Accessing exception information_ section in +[about_Try_Catch_Finally][14]. + ## The -replace operator's substitution scriptblock -Starting in PowerShell 6, you can use `$PSItem` when calling the [replace][12] -operator and defining a [substitution scriptblock][13]. When you do, the value +Starting in PowerShell 6, you can use `$PSItem` when calling the [replace][04] +operator and defining a [substitution scriptblock][05]. When you do, the value of `$PSItem` is the value of the current match. ```powershell @@ -373,28 +399,29 @@ with the default format for the current culture by casting the value to ## See also -- [about_Arrays][04] -- [about_Automatic_Variables][01] -- [about_Comparison_Operators][12] -- [about_Functions][08] -- [about_Script_Blocks][14] -- [about_Switch][07] -- [ForEach-Object][02] -- [Where-Object][03] +- [about_Arrays][01] +- [about_Automatic_Variables][03] +- [about_Comparison_Operators][04] +- [about_Functions][09] +- [about_Script_Blocks][11] +- [about_Switch][13] +- [ForEach-Object][15] +- [Where-Object][16] -[01]: about_Automatic_Variables.md -[02]: xref:Microsoft.PowerShell.Core.ForEach-Object -[03]: xref:Microsoft.PowerShell.Core.Where-Object -[04]: about_Arrays.md#foreach -[05]: about_Arrays.md#where -[06]: about_Script_Blocks.md#using-delay-bind-script-blocks-with-parameters -[07]: about_Switch.md -[08]: about_Functions.md -[09]: about_Functions_Advanced.md -[10]: about_Functions_Advanced_Parameters.md#parameter-attribute -[11]: about_Functions.md#filters -[12]: about_Comparison_Operators.md#replacement-operator -[13]: about_Comparison_Operators.md#replacement-with-a-script-block -[14]: about_Script_Blocks.md -[15]: about_Functions_Advanced_Parameters.md#validatescript-validation-attribute +[01]: about_Arrays.md#foreach +[02]: about_Arrays.md#where +[03]: about_Automatic_Variables.md +[04]: about_Comparison_Operators.md#replacement-operator +[05]: about_Comparison_Operators.md#replacement-with-a-script-block +[06]: about_Functions_Advanced_Parameters.md#parameter-attribute +[07]: about_Functions_Advanced_Parameters.md#validatescript-validation-attribute +[08]: about_Functions_Advanced.md +[09]: about_Functions.md +[10]: about_Functions.md#filters +[11]: about_Script_Blocks.md +[12]: about_Script_Blocks.md#using-delay-bind-script-blocks-with-parameters +[13]: about_Switch.md +[14]: about_Try_Catch_Finally.md#accessing-exception-information +[15]: xref:Microsoft.PowerShell.Core.ForEach-Object +[16]: xref:Microsoft.PowerShell.Core.Where-Object diff --git a/reference/7.5/Microsoft.PowerShell.Core/New-PSSessionOption.md b/reference/7.5/Microsoft.PowerShell.Core/New-PSSessionOption.md index 2dadaa4eadad..16f294cf69de 100644 --- a/reference/7.5/Microsoft.PowerShell.Core/New-PSSessionOption.md +++ b/reference/7.5/Microsoft.PowerShell.Core/New-PSSessionOption.md @@ -272,9 +272,9 @@ remote session, including startup scripts in the session configuration, can find the **ApplicationArguments** property of the `$PSSenderInfo` automatic variable. You can use this parameter to send data to the remote session. -For more information, see [about_Hash_Tables](about/about_Hash_Tables.md), +For more information, see [about_Hash_Tables](About/about_Hash_Tables.md), [about_Session_Configurations](About/about_Session_Configurations.md), and -[about_Automatic_Variables](about/about_Automatic_Variables.md). +[about_Automatic_Variables](About/about_Automatic_Variables.md). ```yaml Type: System.Management.Automation.PSPrimitiveDictionary @@ -339,7 +339,7 @@ The idle time-out value is of significant importance if you intend to disconnect session. You can reconnect only if the session has not timed out. Enter a value in milliseconds. The minimum value is `60000` (1 minute). The maximum is the value of -the **MaxIdleTimeoutms** property of the session configuration. The default value, `-1`, does not +the **MaxIdleTimeoutMs** property of the session configuration. The default value, `-1`, does not set an idle time-out. The session uses the idle time-out that is set in the session options, if any. If none is set diff --git a/reference/7.5/Microsoft.PowerShell.Core/New-PSTransportOption.md b/reference/7.5/Microsoft.PowerShell.Core/New-PSTransportOption.md index 12fbcd281258..2fb4661b303f 100644 --- a/reference/7.5/Microsoft.PowerShell.Core/New-PSTransportOption.md +++ b/reference/7.5/Microsoft.PowerShell.Core/New-PSTransportOption.md @@ -128,7 +128,8 @@ session configuration is 40. ### Example 3: Setting a transport option -This command shows the effect of setting a transport option in a session configuration on the sessions that use the session configuration. +This command shows the effect of setting a transport option in a session configuration on the +sessions that use the session configuration. ```powershell $t = New-PSTransportOption -IdleTimeoutSec 3600 @@ -245,8 +246,8 @@ Accept wildcard characters: False ### -MaxIdleTimeoutSec -Limits the idle time-out set for each session to the specified value. The default value is `[Int]::MaxValue` -(~25 days). +Limits the idle time-out set for each session to the specified value. The default value is +`[Int]::MaxValue` (~25 days). The idle time-out value is of significant importance when the user intends to disconnect and reconnect to a session. The user can reconnect only if the session has not timed out. @@ -400,7 +401,8 @@ Accept wildcard characters: False This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, --WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216). +-WarningAction, and -WarningVariable. For more information, see +[about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216). ## INPUTS diff --git a/reference/7.5/Microsoft.PowerShell.Core/Out-Default.md b/reference/7.5/Microsoft.PowerShell.Core/Out-Default.md index 66d1ea4cd533..d1dbaa5af16a 100644 --- a/reference/7.5/Microsoft.PowerShell.Core/Out-Default.md +++ b/reference/7.5/Microsoft.PowerShell.Core/Out-Default.md @@ -36,8 +36,8 @@ transforms the objects into a stream of Formatting records (driven by the data i definition) and `Out-Host` transforms the formatting records into calls on the Host interface. This cmdlet isn't intended to be used by the end user. Other cmdlets are recommended for controlling -output like [Out-Host](Out-Host.md) or using `Format-*` cmdlets and the [Format.ps1xml](About/about_format.ps1xml.md) -file to control formatting. +output like [Out-Host](Out-Host.md) or using `Format-*` cmdlets and the +[Format.ps1xml](About/about_Format.ps1xml.md) file to control formatting. ## EXAMPLES @@ -100,7 +100,8 @@ Accept wildcard characters: False This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, --WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216). +-WarningAction, and -WarningVariable. For more information, see +[about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216). ## INPUTS diff --git a/reference/7.5/Microsoft.PowerShell.Core/Out-Host.md b/reference/7.5/Microsoft.PowerShell.Core/Out-Host.md index 5fab8dfa0abf..87f05c93b095 100644 --- a/reference/7.5/Microsoft.PowerShell.Core/Out-Host.md +++ b/reference/7.5/Microsoft.PowerShell.Core/Out-Host.md @@ -117,7 +117,8 @@ Accept wildcard characters: False This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, --WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216). +-WarningAction, and -WarningVariable. For more information, see +[about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216). ## INPUTS diff --git a/reference/7.5/Microsoft.PowerShell.Core/Out-Null.md b/reference/7.5/Microsoft.PowerShell.Core/Out-Null.md index 7b2328713b5e..770168d5a4c3 100644 --- a/reference/7.5/Microsoft.PowerShell.Core/Out-Null.md +++ b/reference/7.5/Microsoft.PowerShell.Core/Out-Null.md @@ -57,7 +57,8 @@ Accept wildcard characters: False This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, --WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216). +-WarningAction, and -WarningVariable. For more information, see +[about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216). ## INPUTS diff --git a/reference/7.5/Microsoft.PowerShell.Core/Receive-Job.md b/reference/7.5/Microsoft.PowerShell.Core/Receive-Job.md index 7e44804239e1..6fb18a48bb6c 100644 --- a/reference/7.5/Microsoft.PowerShell.Core/Receive-Job.md +++ b/reference/7.5/Microsoft.PowerShell.Core/Receive-Job.md @@ -67,7 +67,7 @@ When you start a PowerShell background job, the job starts, but the results don' immediately. Instead, the command returns an object that represents the background job. The job object contains useful information about the job, but it doesn't contain the results. This method lets you continue to work in the session while the job runs. For more information about background -jobs in PowerShell, see [about_Jobs](./About/about_Jobs.md). +jobs in PowerShell, see [about_Jobs](About/about_Jobs.md). The `Receive-Job` cmdlet gets the results that have been generated by the time that the `Receive-Job` command is submitted. If the results aren't yet complete, you can run additional @@ -592,7 +592,7 @@ Accept wildcard characters: False This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see -[about_CommonParameters](./About/about_CommonParameters.md). +[about_CommonParameters](About/about_CommonParameters.md). ## INPUTS diff --git a/reference/7.5/Microsoft.PowerShell.Core/Receive-PSSession.md b/reference/7.5/Microsoft.PowerShell.Core/Receive-PSSession.md index 97a2d2a1443b..bab8bd805c80 100644 --- a/reference/7.5/Microsoft.PowerShell.Core/Receive-PSSession.md +++ b/reference/7.5/Microsoft.PowerShell.Core/Receive-PSSession.md @@ -104,10 +104,10 @@ If you use the `Receive-PSSession` cmdlet to connect to a session in which no co or suspended, `Receive-PSSession` connects to the session, but returns no output or errors. For more information about the Disconnected Sessions feature, see -[about_Remote_Disconnected_Sessions](./About/about_Remote_Disconnected_Sessions.md). +[about_Remote_Disconnected_Sessions](About/about_Remote_Disconnected_Sessions.md). Some examples use splatting to reduce the line length and improve readability. For more information, -see [about_Splatting](./About/about_Splatting.md). +see [about_Splatting](About/about_Splatting.md). ## EXAMPLES @@ -179,7 +179,7 @@ disrupts a session connection. PowerShell automatically attempts to reconnect th second for the next four minutes and abandons the effort only if all attempts in the four-minute interval fail. -``` +```powershell PS> $s = New-PSSession -ComputerName Server01 -Name AD -ConfigurationName ADEndpoint PS> $s @@ -248,7 +248,7 @@ commands. And, the script resumed execution and is getting the script results. This example uses the `Receive-PSSession` cmdlet to reconnect to sessions that were intentionally disconnected and get the results of jobs that were running in the sessions. -``` +```powershell PS> $parms = @{ InDisconnectedSession = $True ComputerName = "Server01", "Server02", "Server30" @@ -318,7 +318,7 @@ results are unexpected, the user can run commands in the sessions to investigate This example shows what happens to a job that's running in a disconnected session. -``` +```powershell PS> $s = New-PSSession -ComputerName Server01 -Name Test PS> $j = Invoke-Command -Session $s { 1..1500 | Foreach-Object {"Return $_"; sleep 30}} -AsJob PS> $j @@ -533,7 +533,7 @@ The parameter's value is used to select and filter sessions. It doesn't change t configuration that the session uses. For more information about session configurations, see -[about_Session_Configurations](./About/about_Session_Configurations.md). +[about_Session_Configurations](About/about_Session_Configurations.md). ```yaml Type: System.String @@ -786,9 +786,8 @@ precedence over maximum values, quotas, or limits set in the session configurati For a description of the session options that includes the default values, see `New-PSSessionOption`. For information about the **$PSSessionOption** preference variable, see -[about_Preference_Variables](./About/about_Preference_Variables.md). For more information about -session configurations, see -[about_Session_Configurations](./About/about_Session_Configurations.md). +[about_Preference_Variables](About/about_Preference_Variables.md). For more information about +session configurations, see [about_Session_Configurations](About/about_Session_Configurations.md). ```yaml Type: System.Management.Automation.Remoting.PSSessionOption @@ -977,13 +976,13 @@ When you disconnect a **PSSession**, the session state is Disconnected and the a ## RELATED LINKS -[about_PSSessions](./About/about_PSSessions.md) +[about_PSSessions](About/about_PSSessions.md) -[about_Remote](./About/about_Remote.md) +[about_Remote](About/about_Remote.md) -[about_Remote_Disconnected_Sessions](./About/about_Remote_Disconnected_Sessions.md) +[about_Remote_Disconnected_Sessions](About/about_Remote_Disconnected_Sessions.md) -[about_Session_Configurations](./About/about_Session_Configurations.md) +[about_Session_Configurations](About/about_Session_Configurations.md) [Connect-PSSession](Connect-PSSession.md) diff --git a/reference/7.5/Microsoft.PowerShell.Core/Register-ArgumentCompleter.md b/reference/7.5/Microsoft.PowerShell.Core/Register-ArgumentCompleter.md index 6112c7469bce..c3d1d28b5e2e 100644 --- a/reference/7.5/Microsoft.PowerShell.Core/Register-ArgumentCompleter.md +++ b/reference/7.5/Microsoft.PowerShell.Core/Register-ArgumentCompleter.md @@ -226,7 +226,7 @@ Specifies the name of the parameter the argument completer applies to. The type parameters can't be an enumeration, such as the **ForegroundColor** parameter of the `Write-Host` cmdlet. -For more information on enums, see [about_Enum](./About/about_Enum.md). +For more information on enums, see [about_Enum](About/about_Enum.md). When registering an argument completer for PowerShell commands, always specify this parameter. When you specify the **CommandName** parameter without the **ParameterName** or **Native** parameters, @@ -272,7 +272,7 @@ parameters aren't important because PowerShell passes in the values by position. [CommandAst Class](/dotnet/api/system.management.automation.language.commandast). - `$fakeBoundParameters` (Position 4 **IDictionary**) - This parameter is set to a hashtable containing the `$PSBoundParameters` for the cmdlet, before the user pressed Tab. For - more information, see [about_Automatic_Variables](./About/about_Automatic_Variables.md). + more information, see [about_Automatic_Variables](About/about_Automatic_Variables.md). When you specify the **Native** parameter, the script block must take the following parameters in the specified order. The names of the parameters aren't important because PowerShell passes in the @@ -288,7 +288,7 @@ values by position. when the user pressed Tab. You can also provide an **ArgumentCompleter** as a parameter attribute. For more information, see -[about_Functions_Advanced_Parameters](./About/about_Functions_Advanced_Parameters.md). +[about_Functions_Advanced_Parameters](About/about_Functions_Advanced_Parameters.md). ```yaml Type: System.Management.Automation.ScriptBlock @@ -307,7 +307,7 @@ Accept wildcard characters: False This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see -[about_CommonParameters](./About/about_CommonParameters.md). +[about_CommonParameters](About/about_CommonParameters.md). ## INPUTS @@ -325,4 +325,4 @@ This cmdlet returns no output. ## RELATED LINKS -[about_Functions_Argument_Completion](./About/about_Functions_Argument_Completion.md) +[about_Functions_Argument_Completion](About/about_Functions_Argument_Completion.md) diff --git a/reference/7.5/Microsoft.PowerShell.Core/Register-PSSessionConfiguration.md b/reference/7.5/Microsoft.PowerShell.Core/Register-PSSessionConfiguration.md index dc1679ae76b2..70c59b58d756 100644 --- a/reference/7.5/Microsoft.PowerShell.Core/Register-PSSessionConfiguration.md +++ b/reference/7.5/Microsoft.PowerShell.Core/Register-PSSessionConfiguration.md @@ -120,9 +120,9 @@ This example registers the **AdminShell** session configuration. The `$sessionParams` variable is a hashtable containing all the parameter values. This hashtable is passed to the cmdlet using PowerShell splatting. The `Register-PSSessionConfiguration` command uses -the **SecurityDescriptorSDDL** parameter to specify the SDDL in the value of the `$sddl` variable and -the **MaximumReceivedObjectSizeMB** parameter to increase the object size limit. It also uses the -**StartupScript** parameter to specify a script that configures the session. +the **SecurityDescriptorSDDL** parameter to specify the SDDL in the value of the `$sddl` variable +and the **MaximumReceivedObjectSizeMB** parameter to increase the object size limit. It also uses +the **StartupScript** parameter to specify a script that configures the session. ```powershell $sddl = "O:NSG:BAD:P(A;;GA;;;BA)S:P(AU;FA;GA;;;WD)(AU;FASA;GWGX;;;WD)" @@ -181,8 +181,8 @@ Register-PSSessionConfiguration -Name WithProfile -StartupScript Add-Profile.ps1 The script contains a single command that uses dot sourcing to run the user's **CurrentUserAllHosts** profile in the current scope of the session. -For more information about profiles, see [about_Profiles](./About/about_Profiles.md). For more -information about dot sourcing, see [about_Scopes](./About/about_Scopes.md). +For more information about profiles, see [about_Profiles](About/about_Profiles.md). For more +information about dot sourcing, see [about_Scopes](About/about_Scopes.md). ## PARAMETERS @@ -626,7 +626,8 @@ for this parameter are: The default value is **UseCurrentThread**. -For more information, see [PSThreadOptions Enumeration](/dotnet/api/system.management.automation.runspaces.psthreadoptions?view=powershellsdk-1.1.0). +For more information, see +[PSThreadOptions Enumeration](/dotnet/api/system.management.automation.runspaces.psthreadoptions?view=powershellsdk-1.1.0). ```yaml Type: System.Management.Automation.Runspaces.PSThreadOptions @@ -714,7 +715,8 @@ Accept wildcard characters: False This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, --WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216). +-WarningAction, and -WarningVariable. For more information, see +[about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216). ## INPUTS diff --git a/reference/7.5/Microsoft.PowerShell.Core/Remove-Job.md b/reference/7.5/Microsoft.PowerShell.Core/Remove-Job.md index e7da4e5404b2..b3af797be641 100644 --- a/reference/7.5/Microsoft.PowerShell.Core/Remove-Job.md +++ b/reference/7.5/Microsoft.PowerShell.Core/Remove-Job.md @@ -98,7 +98,7 @@ An alternative is to use the **Job** parameter, such as `Remove-Job -Job $batch` In this example, all the jobs in the current PowerShell session are deleted. ```powershell -Get-job | Remove-Job +Get-Job | Remove-Job ``` `Get-Job` gets all the jobs in the current PowerShell session. The job objects are sent down the @@ -116,7 +116,7 @@ Remove-Job -State NotStarted ### Example 4: Delete jobs by using a friendly name -This example deletes all jobs from the current session with friendly names that end with *batch**, +This example deletes all jobs from the current session with friendly names that end with **batch**, including jobs that are running. ```powershell @@ -410,7 +410,8 @@ Accept wildcard characters: False This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, --WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216). +-WarningAction, and -WarningVariable. For more information, see +[about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216). ## INPUTS @@ -438,11 +439,11 @@ If a job stops before completion and its process hasn't exited, the process is f ## RELATED LINKS -[about_Jobs](./About/about_Jobs.md) +[about_Jobs](About/about_Jobs.md) -[about_Job_Details](./About/about_Job_Details.md) +[about_Job_Details](About/about_Job_Details.md) -[about_Remote_Jobs](./About/about_Remote_Jobs.md) +[about_Remote_Jobs](About/about_Remote_Jobs.md) [Get-Job](Get-Job.md) diff --git a/reference/7.5/Microsoft.PowerShell.Core/Remove-PSSession.md b/reference/7.5/Microsoft.PowerShell.Core/Remove-PSSession.md index 9aa7fb03a71a..477b12c9ab1e 100644 --- a/reference/7.5/Microsoft.PowerShell.Core/Remove-PSSession.md +++ b/reference/7.5/Microsoft.PowerShell.Core/Remove-PSSession.md @@ -110,12 +110,12 @@ with `Serv`. ### Example 4: Close sessions connected to a port ```powershell -Get-PSSession | where {$_.port -eq 90} | Remove-PSSession +Get-PSSession | Where-Object {$_.port -eq 90} | Remove-PSSession ``` This command closes the **PSSessions** that are connected to port 90. You can use this command -format to identify **PSSessions** by properties other than **ComputerName**, **Name**, **InstanceID**, and -**ID**. +format to identify **PSSessions** by properties other than **ComputerName**, **Name**, +**InstanceID**, and **ID**. ### Example 5: Close a session by instance ID @@ -358,7 +358,8 @@ Accept wildcard characters: False This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, --WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216). +-WarningAction, and -WarningVariable. For more information, see +[about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216). ## INPUTS diff --git a/reference/7.5/Microsoft.PowerShell.Core/Save-Help.md b/reference/7.5/Microsoft.PowerShell.Core/Save-Help.md index 5f18197dc5bc..909875dfa49d 100644 --- a/reference/7.5/Microsoft.PowerShell.Core/Save-Help.md +++ b/reference/7.5/Microsoft.PowerShell.Core/Save-Help.md @@ -82,23 +82,25 @@ This cmdlet was introduced in Windows PowerShell 3.0. ### Example 1: Save the help for the DhcpServer module ```powershell -# Option 1: Run Invoke-Command to get the PSModuleInfo object for the remote DHCP Server module, -# save the PSModuleInfo object in the variable $m, and then run Save-Help. +# Option 1: Run Invoke-Command to get the PSModuleInfo object for the remote DHCP Server +# module, save the PSModuleInfo object in the variable $m, and then run Save-Help. $m = Invoke-Command -ComputerName RemoteServer -ScriptBlock { Get-Module -Name DhcpServer -ListAvailable } Save-Help -Module $m -DestinationPath "C:\SavedHelp" -# Option 2: Open a PSSession--targeted at the remote computer that is running the DhcpServer -# module--to get the PSModuleInfo object for the remote module, and then run Save-Help. +# Option 2: Open a PSSession--targeted at the remote computer that is running the +# DhcpServer module--to get the PSModuleInfo object for the remote module, and then run +# Save-Help. $s = New-PSSession -ComputerName "RemoteServer" $m = Get-Module -PSSession $s -Name "DhcpServer" -ListAvailable Save-Help -Module $m -DestinationPath "C:\SavedHelp" -# Option 3: Open a CIM session--targeted at the remote computer that is running the DhcpServer -# module--to get the PSModuleInfo object for the remote module, and then run Save-Help. +# Option 3: Open a CIM session--targeted at the remote computer that is running the +# DhcpServer module--to get the PSModuleInfo object for the remote module, and then run +# Save-Help. $c = New-CimSession -ComputerName "RemoteServer" $m = Get-Module -CimSession $c -Name "DhcpServer" -ListAvailable @@ -112,20 +114,21 @@ the DHCP Server role on the local computer. ### Example 2: Install help for the DhcpServer module ```powershell -# First, run Export-CliXml to export the PSModuleInfo object to a shared folder or to removable media. +# First, run Export-CliXml to export the PSModuleInfo object to a shared folder or to +# removable media. $m = Get-Module -Name "DhcpServer" -ListAvailable Export-CliXml -Path "E:\UsbFlashDrive\DhcpModule.xml" -InputObject $m -# Next, transport the removable media to a computer that has Internet access, and then import the -# PSModuleInfo object with Import-CliXml. Run Save-Help to save the Help for the imported DhcpServer -# module PSModuleInfo object. +# Next, transport the removable media to a computer that has Internet access, and then +# import the PSModuleInfo object with Import-CliXml. Run Save-Help to save the Help for +# the imported DhcpServer module PSModuleInfo object. $deserialized_m = Import-CliXml "E:\UsbFlashDrive\DhcpModule.xml" Save-Help -Module $deserialized_m -DestinationPath "E:\UsbFlashDrive\SavedHelp" -# Finally, transport the removable media back to the computer that does not have network access, and -# then install the help by running Update-Help. +# Finally, transport the removable media back to the computer that does not have network +# access, and then install the help by running Update-Help. Update-Help -Module DhcpServer -SourcePath "E:\UsbFlashDrive\SavedHelp" ``` diff --git a/reference/7.5/Microsoft.PowerShell.Core/Set-PSDebug.md b/reference/7.5/Microsoft.PowerShell.Core/Set-PSDebug.md index 5ae49a185d43..543abd364520 100644 --- a/reference/7.5/Microsoft.PowerShell.Core/Set-PSDebug.md +++ b/reference/7.5/Microsoft.PowerShell.Core/Set-PSDebug.md @@ -195,7 +195,8 @@ Accept wildcard characters: False This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, --WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216). +-WarningAction, and -WarningVariable. For more information, see +[about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216). ## INPUTS @@ -213,7 +214,7 @@ This cmdlet returns no output. ## RELATED LINKS -[about_Debuggers](./About/about_Debuggers.md) +[about_Debuggers](About/about_Debuggers.md) [Debug-Process](../Microsoft.PowerShell.Management/Debug-Process.md) diff --git a/reference/7.5/Microsoft.PowerShell.Core/Set-StrictMode.md b/reference/7.5/Microsoft.PowerShell.Core/Set-StrictMode.md index 9b8a010cf421..89997409e7f5 100644 --- a/reference/7.5/Microsoft.PowerShell.Core/Set-StrictMode.md +++ b/reference/7.5/Microsoft.PowerShell.Core/Set-StrictMode.md @@ -258,7 +258,7 @@ While the **Version** parameter accepts values greater than `3.0`, there are no defined for anything higher than `3.0`. `Set-StrictMode` is effective only in the scope it's set in and in its child scopes. For more -information about scopes in PowerShell, see [about_Scopes](about/about_Scopes.md). +information about scopes in PowerShell, see [about_Scopes](About/about_Scopes.md). ## RELATED LINKS diff --git a/reference/7.5/Microsoft.PowerShell.Core/Start-Job.md b/reference/7.5/Microsoft.PowerShell.Core/Start-Job.md index 5a6438657a39..6ef36e59c512 100644 --- a/reference/7.5/Microsoft.PowerShell.Core/Start-Job.md +++ b/reference/7.5/Microsoft.PowerShell.Core/Start-Job.md @@ -59,11 +59,11 @@ finish. You can continue to work in the session without interruption while the j The job object contains useful information about the job, but it doesn't contain the job results. When the job finishes, use the `Receive-Job` cmdlet to get the results of the job. For more -information about background jobs, see [about_Jobs](./About/about_Jobs.md). +information about background jobs, see [about_Jobs](About/about_Jobs.md). To run a background job on a remote computer, use the **AsJob** parameter that is available on many cmdlets, or use the `Invoke-Command` cmdlet to run a `Start-Job` command on the remote computer. For -more information, see [about_Remote_Jobs](./About/about_Remote_Jobs.md). +more information, see [about_Remote_Jobs](About/about_Remote_Jobs.md). Starting in PowerShell 3.0, `Start-Job` can start instances of custom job types, such as scheduled jobs. For information about how to use `Start-Job` to start jobs with custom types, see the help @@ -72,7 +72,7 @@ documents for the job type feature. Beginning in PowerShell 6.0, you can start jobs using the ampersand (`&`) background operator. The functionality of the background operator is similar to `Start-Job`. Both methods to start a job create a **PSRemotingJob** job object. For more information about using the ampersand (`&`), see -[about_Operators](./about/about_operators.md#background-operator-). +[about_Operators](About/about_Operators.md#background-operator-). PowerShell 7 introduced the **WorkingDirectory** parameter that specifies a background job's initial working directory. If the parameter isn't specified, `Start-Job` defaults to the current working @@ -87,7 +87,8 @@ directory of the caller that started the job. > PowerShell, it's directly using the PowerShell NuGet SDK packages and won't have `pwsh` shipped > along. > -> The substitute in that scenario is `Start-ThreadJob` from the module **[ThreadJob](https://www.powershellgallery.com/packages/ThreadJob)**. +> The substitute in that scenario is `Start-ThreadJob` from the module +> **[ThreadJob](https://www.powershellgallery.com/packages/ThreadJob)**. ## EXAMPLES @@ -257,7 +258,7 @@ The **WorkingDirectory** allows you to specify an alternate directory for a job run scripts or open files. In this example, the background job specifies a working directory that's different than the current directory location. -``` +```powershell PS C:\Test> Start-Job -WorkingDirectory C:\Test\Scripts { $PWD } | Receive-Job -AutoRemoveJob -Wait Path @@ -328,7 +329,7 @@ Specifies an array of arguments, or parameter values, for the script that is spe Arguments must be passed to **ArgumentList** as single-dimension array argument. For example, a comma-separated list. For more information about the behavior of **ArgumentList**, see -[about_Splatting](about/about_Splatting.md#splatting-with-arrays). +[about_Splatting](About/about_Splatting.md#splatting-with-arrays). ```yaml Type: System.Object[] @@ -671,7 +672,8 @@ Accept wildcard characters: False This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, --WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216). +-WarningAction, and -WarningVariable. For more information, see +[about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216). ## INPUTS @@ -699,15 +701,15 @@ the `Invoke-Command` cmdlet to run a `Start-Job` command in a session on a remot ## RELATED LINKS -[about_Arrays](./about/about_arrays.md) +[about_Arrays](About/about_Arrays.md) -[about_Automatic_Variables](./about/about_automatic_variables.md) +[about_Automatic_Variables](About/about_Automatic_Variables.md) -[about_Jobs](./About/about_Jobs.md) +[about_Jobs](About/about_Jobs.md) -[about_Job_Details](./About/about_Job_Details.md) +[about_Job_Details](About/about_Job_Details.md) -[about_Remote_Jobs](./About/about_Remote_Jobs.md) +[about_Remote_Jobs](About/about_Remote_Jobs.md) [Get-Job](Get-Job.md) diff --git a/reference/7.5/Microsoft.PowerShell.Core/Stop-Job.md b/reference/7.5/Microsoft.PowerShell.Core/Stop-Job.md index 3b7858ce028a..1f755d954106 100644 --- a/reference/7.5/Microsoft.PowerShell.Core/Stop-Job.md +++ b/reference/7.5/Microsoft.PowerShell.Core/Stop-Job.md @@ -100,7 +100,7 @@ The third command stops the job. It uses the `Invoke-Command` cmdlet to run a `S the **PSSession** on Server01. Because the job objects are stored in `$j`, which is a variable on the local computer, the command uses the **Using** scope modifier to identify `$j` as a local variable. For more information about the **Using** scope modifier, see -[about_Remote_Variables](about/about_Remote_Variables.md). +[about_Remote_Variables](About/about_Remote_Variables.md). When the command finishes, the job is stopped and the **PSSession** in `$s` is available for use. @@ -434,4 +434,4 @@ PowerShell includes the following aliases for `Stop-Job`: [about_Jobs](About/about_Jobs.md) -[about_Scopes](About/about_scopes.md) +[about_Scopes](About/about_Scopes.md) diff --git a/reference/7.5/Microsoft.PowerShell.Core/TabExpansion2.md b/reference/7.5/Microsoft.PowerShell.Core/TabExpansion2.md index d1019859a832..8cc26cd50126 100644 --- a/reference/7.5/Microsoft.PowerShell.Core/TabExpansion2.md +++ b/reference/7.5/Microsoft.PowerShell.Core/TabExpansion2.md @@ -226,8 +226,8 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable ## RELATED LINKS -[about_Built-in_Functions](./about/about_Built-in_Functions.md) +[about_Built-in_Functions](About/about_Built-in_Functions.md) -[about_Tab_Expansion](./about/about_Tab_Expansion.md) +[about_Tab_Expansion](About/about_Tab_Expansion.md) [CompleteInput() method](xref:System.Management.Automation.CommandCompletion.CompleteInput*) diff --git a/reference/7.5/Microsoft.PowerShell.Core/Test-ModuleManifest.md b/reference/7.5/Microsoft.PowerShell.Core/Test-ModuleManifest.md index 4ee4f99781f4..468a2588d6d5 100644 --- a/reference/7.5/Microsoft.PowerShell.Core/Test-ModuleManifest.md +++ b/reference/7.5/Microsoft.PowerShell.Core/Test-ModuleManifest.md @@ -129,7 +129,8 @@ Accept wildcard characters: True This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, --WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216). +-WarningAction, and -WarningVariable. For more information, see +[about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216). ## INPUTS diff --git a/reference/7.5/Microsoft.PowerShell.Core/Test-PSSessionConfigurationFile.md b/reference/7.5/Microsoft.PowerShell.Core/Test-PSSessionConfigurationFile.md index 8ee81f27fec2..9da5f5c4b3d3 100644 --- a/reference/7.5/Microsoft.PowerShell.Core/Test-PSSessionConfigurationFile.md +++ b/reference/7.5/Microsoft.PowerShell.Core/Test-PSSessionConfigurationFile.md @@ -31,7 +31,8 @@ errors, use the **Verbose** parameter. `Test-PSSessionConfigurationFile` verifies the session configuration files, such as those created by the `New-PSSessionConfigurationFile` cmdlet. For information about session configurations, see [about_Session_Configurations](About/about_Session_Configurations.md). For information about session -configuration files, see [about_Session_Configuration_Files](About/about_Session_Configuration_Files.md). +configuration files, see +[about_Session_Configuration_Files](About/about_Session_Configuration_Files.md). This cmdlet was introduced in PowerShell 3.0. @@ -125,7 +126,8 @@ Accept wildcard characters: True This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, --WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216). +-WarningAction, and -WarningVariable. For more information, see +[about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216). ## INPUTS diff --git a/reference/7.5/Microsoft.PowerShell.Core/Update-Help.md b/reference/7.5/Microsoft.PowerShell.Core/Update-Help.md index f75fcda5cda1..63994b5ee4e4 100644 --- a/reference/7.5/Microsoft.PowerShell.Core/Update-Help.md +++ b/reference/7.5/Microsoft.PowerShell.Core/Update-Help.md @@ -45,7 +45,7 @@ help files can be downloaded and installed from the internet or a file share. Without parameters, `Update-Help` updates the help files for modules that support updateable help and are loaded in the session or installed in a location included in the `$env:PSModulePath`. For -more information, see [about_Updatable_Help](./About/about_Updatable_Help.md). +more information, see [about_Updatable_Help](About/about_Updatable_Help.md). `Update-Help` checks the version of the help installed. If `Update-Help` can't find updated help files for a module it continues silently without displaying an error message. Use the **Force** @@ -447,7 +447,7 @@ you've used the `Save-Help` cmdlet to download updated help files to a directory To specify a default value for **SourcePath**, go to **Group Policy**, **Computer Configuration**, and **Set the default source path for Update-Help**. This Group Policy setting prevents users from using `Update-Help` to download help files from the internet. -For more information, see [about_Group_Policy_Settings](./About/about_Group_Policy_Settings.md). +For more information, see [about_Group_Policy_Settings](About/about_Group_Policy_Settings.md). ```yaml Type: System.String[] diff --git a/reference/7.5/Microsoft.PowerShell.Core/Wait-Job.md b/reference/7.5/Microsoft.PowerShell.Core/Wait-Job.md index dfae5ca02456..5b3b1c8b4a6b 100644 --- a/reference/7.5/Microsoft.PowerShell.Core/Wait-Job.md +++ b/reference/7.5/Microsoft.PowerShell.Core/Wait-Job.md @@ -68,7 +68,8 @@ wait for a job in the `Suspended` or `Disconnected` states. When the commands in the job are complete, `Wait-Job` returns a job object and continues execution. You can use the `Wait-Job` cmdlet to wait for jobs started by using the `Start-Job` cmdlet or the -**AsJob** parameter of the `Invoke-Command` cmdlet. For more information about jobs, see [about_Jobs](./about/about_Jobs.md). +**AsJob** parameter of the `Invoke-Command` cmdlet. For more information about jobs, see +[about_Jobs](About/about_Jobs.md). Starting in Windows PowerShell 3.0, the `Wait-Job` cmdlet also waits for custom job types, such as workflow jobs and instances of scheduled jobs. To enable `Wait-Job` to wait for jobs of a particular @@ -147,7 +148,7 @@ variable. The command uses the **Using** scope modifier to indicate that the `$c` variable was defined on the local computer. The **Using** scope modifier is introduced in Windows PowerShell 3.0. For more information about the **Using** scope modifier, see -[about_Remote_Variables](./about/about_Remote_Variables.md). +[about_Remote_Variables](About/about_Remote_Variables.md). The fourth command uses `Invoke-Command` to run a `Wait-Job` command in the sessions. It uses the **Any** parameter to wait until the first job on the remote computers is terminating state. @@ -184,7 +185,7 @@ The `$done` variable contains a job object that represents the job that ran on S ### Example 5: Wait until one of several jobs finishes ```powershell -Wait-Job -id 1,2,5 -Any +Wait-Job -id 1, 2, 5 -Any ``` This command identifies three jobs by their IDs and waits until any one of them are in a terminating @@ -211,7 +212,7 @@ This command uses the job name to identify the job for which to wait. ### Example 8: Wait for jobs on local computer started with Start-Job ```powershell -$j = Start-Job -ScriptBlock {Get-ChildItem -Filter *.ps1| Where-Object {$PSItem.LastWriteTime -gt ((Get-Date) - (New-TimeSpan -Days 7))}} +$j = Start-Job -ScriptBlock {Get-ChildItem -Filter *.ps1 | Where-Object {$PSItem.LastWriteTime -gt ((Get-Date) - (New-TimeSpan -Days 7))}} $j | Wait-Job ``` @@ -505,7 +506,8 @@ By default, `Wait-Job` returns, or ends the wait, when jobs are in one of the fo - Suspended - Disconnected -To direct `Wait-Job` to continue to wait for Suspended and Disconnected jobs, use the **Force** parameter. +To direct `Wait-Job` to continue to wait for Suspended and Disconnected jobs, use the **Force** +parameter. ## RELATED LINKS diff --git a/reference/7.5/Microsoft.PowerShell.Core/Where-Object.md b/reference/7.5/Microsoft.PowerShell.Core/Where-Object.md index af70217893c2..8c96de47a9b8 100644 --- a/reference/7.5/Microsoft.PowerShell.Core/Where-Object.md +++ b/reference/7.5/Microsoft.PowerShell.Core/Where-Object.md @@ -258,7 +258,7 @@ command. `Get-Process | Where-Object {$_.PriorityClass -eq "Normal"}` All PowerShell comparison operators are valid in the script block format. For more information, - see [about_Comparison_Operators](./About/about_Comparison_Operators.md). + see [about_Comparison_Operators](About/about_Comparison_Operators.md). - **Comparison statement**. You can also write a comparison statement, which is much more like natural language. Comparison statements were introduced in Windows PowerShell 3.0. @@ -285,7 +285,7 @@ The previous example is functionally equivalent to: - `('hi', '', 'there') | Where-Object { $_.Length -gt 0 }` For more information about how PowerShell evaluates booleans, see -[about_Booleans](about/about_Booleans.md). +[about_Booleans](About/about_Booleans.md). ## EXAMPLES @@ -400,9 +400,9 @@ The example uses the script block command format. Logical operators, such as `-a `Where-Object` command. - For more information about PowerShell logical operators, see - [about_Logical_Operators](./About/about_logical_operators.md). + [about_Logical_Operators](About/about_Logical_Operators.md). - For more information about the Updatable Help feature, see - [about_Updatable_Help](./About/about_Updatable_Help.md). + [about_Updatable_Help](About/about_Updatable_Help.md). ## PARAMETERS @@ -1188,7 +1188,7 @@ PowerShell includes the following aliases for `Where-Object`: Starting in Windows PowerShell 4.0, `Where` and `ForEach` methods were added for use with collections. -You can read more about these methods here [about_arrays](./About/about_Arrays.md) +You can read more about these methods here [about_arrays](About/about_Arrays.md) ## RELATED LINKS @@ -1208,4 +1208,4 @@ You can read more about these methods here [about_arrays](./About/about_Arrays.m [Tee-Object](../Microsoft.PowerShell.Utility/Tee-Object.md) -[about_Booleans](about/about_Booleans.md) +[about_Booleans](About/about_Booleans.md) diff --git a/reference/7.6/Microsoft.PowerShell.Core/About/about_PSItem.md b/reference/7.6/Microsoft.PowerShell.Core/About/about_PSItem.md index 9d32f58f894f..852371f02ab1 100644 --- a/reference/7.6/Microsoft.PowerShell.Core/About/about_PSItem.md +++ b/reference/7.6/Microsoft.PowerShell.Core/About/about_PSItem.md @@ -1,7 +1,7 @@ --- description: The automatic variable that contains the current object in the pipeline object. Locale: en-US -ms.date: 12/07/2022 +ms.date: 01/31/2025 online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_psitem?view=powershell-7.6&WT.mc_id=ps-gethelp schema: 2.0.0 title: about_PSItem @@ -15,7 +15,7 @@ The automatic variable that contains the current object in the pipeline object. ## Long description PowerShell includes the `$PSItem` variable and its alias, `$_`, as -[automatic variables][01] in scriptblocks that process the current object, such +[automatic variables][03] in scriptblocks that process the current object, such as in the pipeline. This article uses `$PSItem` in the examples, but `$PSItem` can be replaced with `$_` in every example. @@ -24,24 +24,25 @@ a pipeline. There are a few common use cases for `$PSItem`: -- in the scriptblock for the **Process** parameter of the +- In the scriptblock for the **Process** parameter of the `ForEach-Object`cmdlet -- in the scriptblock for the **FilterScript** parameter of the `Where-Object` +- In the scriptblock for the **FilterScript** parameter of the `Where-Object` cmdlet -- in the intrinsic methods **ForEach** and **Where** +- In the intrinsic methods **ForEach** and **Where** - with delay-bind scriptblock parameters -- in a `switch` statement's conditional values and associated scriptblocks -- in the `process` block of a function -- in a `filter` definition -- in the scriptblock of the **ValidateScript** attribute -- in the substitution operand scriptblock of the `-replace` operator +- In a `switch` statement's conditional values and associated scriptblocks +- In the `process` block of a function +- In a `filter` definition +- In the scriptblock of the **ValidateScript** attribute +- In the scriptblock of a `catch` statement +- In the substitution operand scriptblock of the `-replace` operator The rest of this article includes examples of using `$PSItem` for these use cases. ## ForEach-Object Process -The [ForEach-Object][02] cmdlet is designed to operate on objects in the +The [ForEach-Object][15] cmdlet is designed to operate on objects in the pipeline, executing the **Process** parameter's scriptblock once for every object in the pipeline. @@ -76,7 +77,7 @@ Result is: 2 3 4 ## Where-Object FilterScript -The [Where-Object][03] cmdlet is designed to filter objects in the pipeline. +The [Where-Object][16] cmdlet is designed to filter objects in the pipeline. You can use `$PSItem` in the scriptblock of the **FilterScript** parameter, which executes once for each input object in the pipeline. @@ -95,7 +96,7 @@ list. ## ForEach and Where methods -Both the [ForEach][04] and [Where][05] intrinsic methods for arrays take a +Both the [ForEach][01] and [Where][02] intrinsic methods for arrays take a scriptblock as an input parameter. You can use the `$PSItem` in those scriptblocks to access the current object. @@ -112,7 +113,7 @@ current object. Then the scriptblock of the **Where** method returns only `B`. ## Delay-bind scriptblock parameters -[Delay-bind scriptblocks][06] let you use `$PSItem` to define parameters for a +[Delay-bind scriptblocks][12] let you use `$PSItem` to define parameters for a pipelined cmdlet before executing it. ```powershell @@ -121,7 +122,7 @@ dir config.log | Rename-Item -NewName { "old_$($_.Name)" } ## Switch statement scriptblocks -In [switch statements][07], you can use `$PSItem` in both action scriptblocks +In [switch statements][13], you can use `$PSItem` in both action scriptblocks and statement condition scriptblocks. ```powershell @@ -148,7 +149,7 @@ the current object is odd. ## Function process blocks -When you define a [function][08], you can use `$PSItem` in the `process` block +When you define a [function][09], you can use `$PSItem` in the `process` block definition but not in the `begin` or `end` block definitions. If you reference `$PSItem` in the `begin` or `end` blocks, the value is `$null` because those blocks don't operate on each object in the pipeline. @@ -172,10 +173,10 @@ function Add-One { ``` > [!TIP] -> While you can use `$PSItem` in [advanced functions][09], there's little +> While you can use `$PSItem` in [advanced functions][08], there's little > reason to do so. If you intend to receive input from the pipeline, > it's best to define parameters with one of the `ValueFromPipeline*` arguments -> for the [Parameter][10] attribute. +> for the [Parameter][06] attribute. Using the **Parameter** attribute and cmdlet binding for advanced functions makes the implementation more explicit and predictable than processing the @@ -276,7 +277,7 @@ VERBOSE: Input object 3 is: ## Filter definitions -You can use `$PSItem` in the statement list of a [filter][11]'s definition. +You can use `$PSItem` in the statement list of a [filter][10]'s definition. When you use `$PSItem` in a `filter` definition, the value is the current object if the filter is called in the pipeline and otherwise `$null`. @@ -298,7 +299,7 @@ is an even number and `$false` if it isn't. ## The ValidateScript attribute scriptblock -You can use `$PSItem` in the scriptblock of a [ValidateScript][15] attribute. +You can use `$PSItem` in the scriptblock of a [ValidateScript][07] attribute. When used with **ValidateScript**, `$PSItem` is the value of the current object being validated. When the variable or parameter value is an array, the scriptblock is called once for each object in the array with `$PSItem` as the @@ -352,10 +353,35 @@ value isn't even. The `Add-EvenNumber` function adds the valid input numbers and returns the total. +## The catch statement scriptblock + +Within a `catch` block, the current error can be accessed using `$PSItem`. The +object is of type **ErrorRecord**. + +```powershell +try { NonsenseString } +catch { + Write-Host "An error occurred:" + Write-Host $_ +} +``` + +Running this script returns the following result: + +```Output +An Error occurred: +The term 'NonsenseString' is not recognized as the name of a cmdlet, function, +script file, or operable program. Check the spelling of the name, or if a path +was included, verify that the path is correct and try again. +``` + +For more examples, see the _Accessing exception information_ section in +[about_Try_Catch_Finally][14]. + ## The -replace operator's substitution scriptblock -Starting in PowerShell 6, you can use `$PSItem` when calling the [replace][12] -operator and defining a [substitution scriptblock][13]. When you do, the value +Starting in PowerShell 6, you can use `$PSItem` when calling the [replace][04] +operator and defining a [substitution scriptblock][05]. When you do, the value of `$PSItem` is the value of the current match. ```powershell @@ -373,28 +399,29 @@ with the default format for the current culture by casting the value to ## See also -- [about_Arrays][04] -- [about_Automatic_Variables][01] -- [about_Comparison_Operators][12] -- [about_Functions][08] -- [about_Script_Blocks][14] -- [about_Switch][07] -- [ForEach-Object][02] -- [Where-Object][03] +- [about_Arrays][01] +- [about_Automatic_Variables][03] +- [about_Comparison_Operators][04] +- [about_Functions][09] +- [about_Script_Blocks][11] +- [about_Switch][13] +- [ForEach-Object][15] +- [Where-Object][16] -[01]: about_Automatic_Variables.md -[02]: xref:Microsoft.PowerShell.Core.ForEach-Object -[03]: xref:Microsoft.PowerShell.Core.Where-Object -[04]: about_Arrays.md#foreach -[05]: about_Arrays.md#where -[06]: about_Script_Blocks.md#using-delay-bind-script-blocks-with-parameters -[07]: about_Switch.md -[08]: about_Functions.md -[09]: about_Functions_Advanced.md -[10]: about_Functions_Advanced_Parameters.md#parameter-attribute -[11]: about_Functions.md#filters -[12]: about_Comparison_Operators.md#replacement-operator -[13]: about_Comparison_Operators.md#replacement-with-a-script-block -[14]: about_Script_Blocks.md -[15]: about_Functions_Advanced_Parameters.md#validatescript-validation-attribute +[01]: about_Arrays.md#foreach +[02]: about_Arrays.md#where +[03]: about_Automatic_Variables.md +[04]: about_Comparison_Operators.md#replacement-operator +[05]: about_Comparison_Operators.md#replacement-with-a-script-block +[06]: about_Functions_Advanced_Parameters.md#parameter-attribute +[07]: about_Functions_Advanced_Parameters.md#validatescript-validation-attribute +[08]: about_Functions_Advanced.md +[09]: about_Functions.md +[10]: about_Functions.md#filters +[11]: about_Script_Blocks.md +[12]: about_Script_Blocks.md#using-delay-bind-script-blocks-with-parameters +[13]: about_Switch.md +[14]: about_Try_Catch_Finally.md#accessing-exception-information +[15]: xref:Microsoft.PowerShell.Core.ForEach-Object +[16]: xref:Microsoft.PowerShell.Core.Where-Object