Service | Microsoft Docs article | Related commit history on GitHub | Change details |
---|---|---|---|
Microsoft.PowerShell.Core | About Foreach (5.1) | https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/5.1/Microsoft.PowerShell.Core/About/about_Foreach.md | --- description: Describes a language command you can use to traverse all the items in a collection of items. Locale: en-US Previously updated : 02/27/2019 Last updated : 01/18/2022 online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.core/about/about_foreach?view=powershell-5.1&WT.mc_id=ps-gethelp schema: 2.0.0 Title: about Foreach collection of items. ## Long description -The `Foreach` statement (also known as a `Foreach` loop) is a language construct +The `foreach` statement (also known as a `foreach` loop) is a language construct for stepping through (iterating) a series of values in a collection of items. The simplest and most typical type of collection to traverse is an array.-Within a `Foreach` loop, it is common to run one or more commands against each +Within a `foreach` loop, it is common to run one or more commands against each item in an array. ## Syntax -The following shows the `ForEach` syntax: +The following shows the `foreach` syntax: ``` foreach ($<item> in $<collection>){<statement list>} ``` -The part of the `ForEach` statement enclosed in parenthesis represents a +The part of the `foreach` statement enclosed in parenthesis represents a variable and a collection to iterate. PowerShell creates the variable-`$<item>` automatically when the `Foreach` loop runs. Prior to each +`$<item>` automatically when the `foreach` loop runs. Prior to each iteration through the loop, the variable is set to a value in the collection.-The block following a `Foreach` statement `{<statement list>}` contains a set +The block following a `foreach` statement `{<statement list>}` contains a set of commands to execute against each item in a collection. ### Examples -For example, the `Foreach` loop in the following example displays the values +For example, the `foreach` loop in the following example displays the values in the `$letterArray` array. ```powershell foreach ($letter in $letterArray) ``` In this example, the `$letterArray` array is created and initialized with the-string values `"a"`, `"b"`, `"c"`, and `"d"`. The first time the `Foreach` +string values `"a"`, `"b"`, `"c"`, and `"d"`. The first time the `foreach` statement runs, it sets the `$letter` variable equal to the first item in `$letterArray` (`"a"`). Then, it uses the `Write-Host` cmdlet to display the letter a. The next time through the loop, `$letter` is set to `"b"`, and so-on. After the `Foreach` loop displays the letter d, PowerShell exits +on. After the `foreach` loop displays the letter d, PowerShell exits the loop. -The entire `Foreach` statement must appear on a single line to run it as a -command at the PowerShell command prompt. The entire `Foreach` statement does -not have to appear on a single line if you place the command in a .ps1 script -file instead. --`Foreach` statements can also be used together with cmdlets that return a +`foreach` statements can also be used together with cmdlets that return a collection of items. In the following example, the Foreach statement steps through the list of items that is returned by the `Get-ChildItem` cmdlet. foreach ($file in Get-ChildItem) } ``` -You can refine the example by using an `If` statement to limit the results -that are returned. In the following example, the `Foreach` statement performs -the same looping operation as the previous example, but it adds an `If` +You can refine the example by using an `if` statement to limit the results +that are returned. In the following example, the `foreach` statement performs +the same looping operation as the previous example, but it adds an `if` statement to limit the results to files that are greater than 100 kilobytes (KB): foreach ($file in Get-ChildItem) } ``` -In this example, the `Foreach` loop uses a property of the `$file` variable to +In this example, the `foreach` loop uses a property of the `$file` variable to perform a comparison operation (`$file.length -gt 100KB`). The `$file` variable contains all the properties in the object that is returned by the `Get-ChildItem` cmdlet. Therefore, you can return more than just a file name. foreach ($file in Get-ChildItem) In this example, you are not limited to running a single command in a statement list. -You can also use a variable outside a `Foreach` loop and increment the +You can also use a variable outside a `foreach` loop and increment the variable inside the loop. The following example counts files over 100 KB in size: else { In the preceding example, the `$i` variable is set to `0` outside the loop, and the variable is incremented inside the loop for each file that is found-that is larger than 100 KB. When the loop exits, an `If` statement evaluates +that is larger than 100 KB. When the loop exits, an `if` statement evaluates the value of `$i` to display a count of all the files over 100 KB. Or, it displays a message stating that no files over 100 KB were found. |
Microsoft.PowerShell.Core | About While (5.1) | https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/5.1/Microsoft.PowerShell.Core/About/about_While.md | --- description: Describes a language statement that you can use to run a command block based on the results of a conditional test. Locale: en-US Previously updated : 06/10/2021 Last updated : 01/18/2022 online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.core/about/about_while?view=powershell-5.1&WT.mc_id=ps-gethelp schema: 2.0.0 Title: about While the results of a conditional test. ## Long description -The `While` statement (also known as a `While` loop) is a language construct +The `while` statement (also known as a `while` loop) is a language construct for creating a loop that runs commands in a command block as long as a-conditional test evaluates to true. The `While` statement is easier to +conditional test evaluates to true. The `while` statement is easier to construct than a For statement because its syntax is less complicated. In addition, it is more flexible than the Foreach statement because you specify a-conditional test in the `While` statement to control how many times the loop +conditional test in the `while` statement to control how many times the loop runs. The following shows the While statement syntax: The following shows the While statement syntax: while (<condition>){<statement list>} ``` -When you run a While statement, PowerShell evaluates the `<condition>` section +When you run a `while` statement, PowerShell evaluates the `<condition>` section of the statement before entering the `<statement list>` section. The condition portion of the statement resolves to either true or false. As long as the condition remains true, PowerShell reruns the `<statement list>` section. For more information about how booleans are evaluated, see [about_Booleans](about_Booleans.md). The `<statement list>` section of the statement contains one or more commands-that are run each time the loop is entered or repeated. +that are run each time the loop is entered or repeated. The `<statement list>` +can contain any valid PowerShell statements, including the `break` and +`continue` keywords. -For example, the following While statement displays the numbers 1 through 3 if +For example, the following `while` statement displays the numbers 1 through 3 if the `$val` variable has not been created or if the `$val` variable has been created and initialized to 0. the second command that writes the value of `$val` to the console. ## See also - [about_Comparison_Operators](about_Comparison_Operators.md)+- [about_Break](about_Break.md) +- [about_Continue](about_Continue.md) - [about_Do](about_Do.md) - [about_Foreach](about_Foreach.md) - [about_For](about_For.md) |
Microsoft.PowerShell.Management | Copy Item (5.1) | https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/5.1/Microsoft.PowerShell.Management/Copy-Item.md | external help file: Microsoft.PowerShell.Commands.Management.dll-Help.xml Locale: en-US Module Name: Microsoft.PowerShell.Management Previously updated : 08/25/2020 Last updated : 01/18/2022 online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.management/copy-item?view=powershell-5.1&WT.mc_id=ps-gethelp schema: 2.0.0 Title: Copy-Item Copy-Item -Path "C:\Logfiles\*" -Destination "C:\Drawings" -Recurse > For example: > > `Copy-Item -Path "C:\Logfiles" -Destination "C:\Drawings" -Recurse`+> +> If the path `C:\Drawings` does not exist the cmdlet copies all the files from the `Logfiles` folder +> into a single file `C:\Drawings`. ### Example 3: Copy directory and contents to a new directory |
Microsoft.PowerShell.Management | New Psdrive (5.1) | https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/5.1/Microsoft.PowerShell.Management/New-PSDrive.md | external help file: Microsoft.PowerShell.Commands.Management.dll-Help.xml Locale: en-US Module Name: Microsoft.PowerShell.Management Previously updated : 10/22/2019 Last updated : 01/18/2022 online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.management/new-psdrive?view=powershell-5.1&WT.mc_id=ps-gethelp schema: 2.0.0 Title: New-PSDrive Title: New-PSDrive # New-PSDrive ## Synopsis-Creates temporary and persistent mapped network drives. +Creates temporary and persistent drives that are associated with a location in an item data store. ## Syntax |
Microsoft.PowerShell.Core | About Foreach (7.0) | https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/7.0/Microsoft.PowerShell.Core/About/about_Foreach.md | --- description: Describes a language command you can use to traverse all the items in a collection of items. Locale: en-US Previously updated : 02/27/2019 Last updated : 01/18/2022 online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.core/about/about_foreach?view=powershell-7&WT.mc_id=ps-gethelp schema: 2.0.0 Title: about Foreach collection of items. ## Long description -The `Foreach` statement (also known as a `Foreach` loop) is a language construct +The `foreach` statement (also known as a `foreach` loop) is a language construct for stepping through (iterating) a series of values in a collection of items. The simplest and most typical type of collection to traverse is an array.-Within a `Foreach` loop, it is common to run one or more commands against each +Within a `foreach` loop, it is common to run one or more commands against each item in an array. ## Syntax -The following shows the `ForEach` syntax: +The following shows the `foreach` syntax: ``` foreach ($<item> in $<collection>){<statement list>} ``` -The part of the `ForEach` statement enclosed in parenthesis represents a +The part of the `foreach` statement enclosed in parenthesis represents a variable and a collection to iterate. PowerShell creates the variable-`$<item>` automatically when the `Foreach` loop runs. Prior to each +`$<item>` automatically when the `foreach` loop runs. Prior to each iteration through the loop, the variable is set to a value in the collection.-The block following a `Foreach` statement `{<statement list>}` contains a set +The block following a `foreach` statement `{<statement list>}` contains a set of commands to execute against each item in a collection. ### Examples -For example, the `Foreach` loop in the following example displays the values +For example, the `foreach` loop in the following example displays the values in the `$letterArray` array. ```powershell foreach ($letter in $letterArray) ``` In this example, the `$letterArray` array is created and initialized with the-string values `"a"`, `"b"`, `"c"`, and `"d"`. The first time the `Foreach` +string values `"a"`, `"b"`, `"c"`, and `"d"`. The first time the `foreach` statement runs, it sets the `$letter` variable equal to the first item in `$letterArray` (`"a"`). Then, it uses the `Write-Host` cmdlet to display the letter a. The next time through the loop, `$letter` is set to `"b"`, and so-on. After the `Foreach` loop displays the letter d, PowerShell exits +on. After the `foreach` loop displays the letter d, PowerShell exits the loop. -The entire `Foreach` statement must appear on a single line to run it as a -command at the PowerShell command prompt. The entire `Foreach` statement does -not have to appear on a single line if you place the command in a .ps1 script -file instead. --`Foreach` statements can also be used together with cmdlets that return a +`foreach` statements can also be used together with cmdlets that return a collection of items. In the following example, the Foreach statement steps through the list of items that is returned by the `Get-ChildItem` cmdlet. foreach ($file in Get-ChildItem) } ``` -You can refine the example by using an `If` statement to limit the results -that are returned. In the following example, the `Foreach` statement performs -the same looping operation as the previous example, but it adds an `If` +You can refine the example by using an `if` statement to limit the results +that are returned. In the following example, the `foreach` statement performs +the same looping operation as the previous example, but it adds an `if` statement to limit the results to files that are greater than 100 kilobytes (KB): foreach ($file in Get-ChildItem) } ``` -In this example, the `Foreach` loop uses a property of the `$file` variable to +In this example, the `foreach` loop uses a property of the `$file` variable to perform a comparison operation (`$file.length -gt 100KB`). The `$file` variable contains all the properties in the object that is returned by the `Get-ChildItem` cmdlet. Therefore, you can return more than just a file name. foreach ($file in Get-ChildItem) In this example, you are not limited to running a single command in a statement list. -You can also use a variable outside a `Foreach` loop and increment the +You can also use a variable outside a `foreach` loop and increment the variable inside the loop. The following example counts files over 100 KB in size: else { In the preceding example, the `$i` variable is set to `0` outside the loop, and the variable is incremented inside the loop for each file that is found-that is larger than 100 KB. When the loop exits, an `If` statement evaluates +that is larger than 100 KB. When the loop exits, an `if` statement evaluates the value of `$i` to display a count of all the files over 100 KB. Or, it displays a message stating that no files over 100 KB were found. function Get-FunctionPosition { $filesToProcess = if ($_ -is [System.IO.FileSystemInfo]) { $_ } else {- $filesToProcess = Get-Item -Path $Path + Get-Item -Path $Path } $parser = [System.Management.Automation.Language.Parser] foreach ($item in $filesToProcess) { |
Microsoft.PowerShell.Core | About While (7.0) | https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/7.0/Microsoft.PowerShell.Core/About/about_While.md | --- description: Describes a language statement that you can use to run a command block based on the results of a conditional test. Locale: en-US Previously updated : 06/10/2021 Last updated : 01/18/2022 online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.core/about/about_while?view=powershell-7&WT.mc_id=ps-gethelp schema: 2.0.0 Title: about While the results of a conditional test. ## Long description -The `While` statement (also known as a `While` loop) is a language construct +The `while` statement (also known as a `while` loop) is a language construct for creating a loop that runs commands in a command block as long as a-conditional test evaluates to true. The `While` statement is easier to +conditional test evaluates to true. The `while` statement is easier to construct than a For statement because its syntax is less complicated. In addition, it is more flexible than the Foreach statement because you specify a-conditional test in the `While` statement to control how many times the loop +conditional test in the `while` statement to control how many times the loop runs. The following shows the While statement syntax: The following shows the While statement syntax: while (<condition>){<statement list>} ``` -When you run a While statement, PowerShell evaluates the `<condition>` section +When you run a `while` statement, PowerShell evaluates the `<condition>` section of the statement before entering the `<statement list>` section. The condition portion of the statement resolves to either true or false. As long as the condition remains true, PowerShell reruns the `<statement list>` section. For more information about how booleans are evaluated, see [about_Booleans](about_Booleans.md). The `<statement list>` section of the statement contains one or more commands-that are run each time the loop is entered or repeated. +that are run each time the loop is entered or repeated. The `<statement list>` +can contain any valid PowerShell statements, including the `break` and +`continue` keywords. -For example, the following While statement displays the numbers 1 through 3 if +For example, the following `while` statement displays the numbers 1 through 3 if the `$val` variable has not been created or if the `$val` variable has been created and initialized to 0. the second command that writes the value of `$val` to the console. ## See also - [about_Comparison_Operators](about_Comparison_Operators.md)+- [about_Break](about_Break.md) +- [about_Continue](about_Continue.md) - [about_Do](about_Do.md) - [about_Foreach](about_Foreach.md) - [about_For](about_For.md) |
Microsoft.PowerShell.Management | Copy Item (7.0) | https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/7.0/Microsoft.PowerShell.Management/Copy-Item.md | external help file: Microsoft.PowerShell.Commands.Management.dll-Help.xml Locale: en-US Module Name: Microsoft.PowerShell.Management Previously updated : 08/25/2020 Last updated : 01/18/2022 online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.management/copy-item?view=powershell-7&WT.mc_id=ps-gethelp schema: 2.0.0 Title: Copy-Item Copy-Item -Path "C:\Logfiles\*" -Destination "C:\Drawings" -Recurse > For example: > > `Copy-Item -Path "C:\Logfiles" -Destination "C:\Drawings" -Recurse`+> +> If the path `C:\Drawings` does not exist the cmdlet copies all the files from the `Logfiles` folder +> into a single file `C:\Drawings`. ### Example 3: Copy directory and contents to a new directory |
Microsoft.PowerShell.Management | New Psdrive (7.0) | https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/7.0/Microsoft.PowerShell.Management/New-PSDrive.md | external help file: Microsoft.PowerShell.Commands.Management.dll-Help.xml Locale: en-US Module Name: Microsoft.PowerShell.Management Previously updated : 10/22/2019 Last updated : 01/18/2022 online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.management/new-psdrive?view=powershell-7&WT.mc_id=ps-gethelp schema: 2.0.0 Title: New-PSDrive Title: New-PSDrive # New-PSDrive ## Synopsis-Creates temporary and persistent mapped network drives. +Creates temporary and persistent drives that are associated with a location in an item data store. ## Syntax |
Microsoft.PowerShell.Core | About Foreach (7.1) | https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/7.1/Microsoft.PowerShell.Core/About/about_Foreach.md | --- description: Describes a language command you can use to traverse all the items in a collection of items. Locale: en-US Previously updated : 02/27/2019 Last updated : 01/18/2022 online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.core/about/about_foreach?view=powershell-7.1&WT.mc_id=ps-gethelp schema: 2.0.0 Title: about Foreach collection of items. ## Long description -The `Foreach` statement (also known as a `Foreach` loop) is a language construct +The `foreach` statement (also known as a `foreach` loop) is a language construct for stepping through (iterating) a series of values in a collection of items. The simplest and most typical type of collection to traverse is an array.-Within a `Foreach` loop, it is common to run one or more commands against each +Within a `foreach` loop, it is common to run one or more commands against each item in an array. ## Syntax -The following shows the `ForEach` syntax: +The following shows the `foreach` syntax: ``` foreach ($<item> in $<collection>){<statement list>} ``` -The part of the `ForEach` statement enclosed in parenthesis represents a +The part of the `foreach` statement enclosed in parenthesis represents a variable and a collection to iterate. PowerShell creates the variable-`$<item>` automatically when the `Foreach` loop runs. Prior to each +`$<item>` automatically when the `foreach` loop runs. Prior to each iteration through the loop, the variable is set to a value in the collection.-The block following a `Foreach` statement `{<statement list>}` contains a set +The block following a `foreach` statement `{<statement list>}` contains a set of commands to execute against each item in a collection. ### Examples -For example, the `Foreach` loop in the following example displays the values +For example, the `foreach` loop in the following example displays the values in the `$letterArray` array. ```powershell foreach ($letter in $letterArray) ``` In this example, the `$letterArray` array is created and initialized with the-string values `"a"`, `"b"`, `"c"`, and `"d"`. The first time the `Foreach` +string values `"a"`, `"b"`, `"c"`, and `"d"`. The first time the `foreach` statement runs, it sets the `$letter` variable equal to the first item in `$letterArray` (`"a"`). Then, it uses the `Write-Host` cmdlet to display the letter a. The next time through the loop, `$letter` is set to `"b"`, and so-on. After the `Foreach` loop displays the letter d, PowerShell exits +on. After the `foreach` loop displays the letter d, PowerShell exits the loop. -The entire `Foreach` statement must appear on a single line to run it as a -command at the PowerShell command prompt. The entire `Foreach` statement does -not have to appear on a single line if you place the command in a .ps1 script -file instead. --`Foreach` statements can also be used together with cmdlets that return a +`foreach` statements can also be used together with cmdlets that return a collection of items. In the following example, the Foreach statement steps through the list of items that is returned by the `Get-ChildItem` cmdlet. foreach ($file in Get-ChildItem) } ``` -You can refine the example by using an `If` statement to limit the results -that are returned. In the following example, the `Foreach` statement performs -the same looping operation as the previous example, but it adds an `If` +You can refine the example by using an `if` statement to limit the results +that are returned. In the following example, the `foreach` statement performs +the same looping operation as the previous example, but it adds an `if` statement to limit the results to files that are greater than 100 kilobytes (KB): foreach ($file in Get-ChildItem) } ``` -In this example, the `Foreach` loop uses a property of the `$file` variable to +In this example, the `foreach` loop uses a property of the `$file` variable to perform a comparison operation (`$file.length -gt 100KB`). The `$file` variable contains all the properties in the object that is returned by the `Get-ChildItem` cmdlet. Therefore, you can return more than just a file name. foreach ($file in Get-ChildItem) In this example, you are not limited to running a single command in a statement list. -You can also use a variable outside a `Foreach` loop and increment the +You can also use a variable outside a `foreach` loop and increment the variable inside the loop. The following example counts files over 100 KB in size: else { In the preceding example, the `$i` variable is set to `0` outside the loop, and the variable is incremented inside the loop for each file that is found-that is larger than 100 KB. When the loop exits, an `If` statement evaluates +that is larger than 100 KB. When the loop exits, an `if` statement evaluates the value of `$i` to display a count of all the files over 100 KB. Or, it displays a message stating that no files over 100 KB were found. function Get-FunctionPosition { $filesToProcess = if ($_ -is [System.IO.FileSystemInfo]) { $_ } else {- $filesToProcess = Get-Item -Path $Path + Get-Item -Path $Path } $parser = [System.Management.Automation.Language.Parser] foreach ($item in $filesToProcess) { function Get-FunctionPosition { [about_If](about_If.md) [ForEach-Object](xref:Microsoft.PowerShell.Core.ForEach-Object)- |
Microsoft.PowerShell.Core | About While (7.1) | https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/7.1/Microsoft.PowerShell.Core/About/about_While.md | --- description: Describes a language statement that you can use to run a command block based on the results of a conditional test. Locale: en-US Previously updated : 06/10/2021 Last updated : 01/18/2022 online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.core/about/about_while?view=powershell-7.1&WT.mc_id=ps-gethelp schema: 2.0.0 Title: about While the results of a conditional test. ## Long description -The `While` statement (also known as a `While` loop) is a language construct +The `while` statement (also known as a `while` loop) is a language construct for creating a loop that runs commands in a command block as long as a-conditional test evaluates to true. The `While` statement is easier to +conditional test evaluates to true. The `while` statement is easier to construct than a For statement because its syntax is less complicated. In addition, it is more flexible than the Foreach statement because you specify a-conditional test in the `While` statement to control how many times the loop +conditional test in the `while` statement to control how many times the loop runs. The following shows the While statement syntax: The following shows the While statement syntax: while (<condition>){<statement list>} ``` -When you run a While statement, PowerShell evaluates the `<condition>` section +When you run a `while` statement, PowerShell evaluates the `<condition>` section of the statement before entering the `<statement list>` section. The condition portion of the statement resolves to either true or false. As long as the condition remains true, PowerShell reruns the `<statement list>` section. For more information about how booleans are evaluated, see [about_Booleans](about_Booleans.md). The `<statement list>` section of the statement contains one or more commands-that are run each time the loop is entered or repeated. +that are run each time the loop is entered or repeated. The `<statement list>` +can contain any valid PowerShell statements, including the `break` and +`continue` keywords. -For example, the following While statement displays the numbers 1 through 3 if +For example, the following `while` statement displays the numbers 1 through 3 if the `$val` variable has not been created or if the `$val` variable has been created and initialized to 0. the second command that writes the value of `$val` to the console. ## See also - [about_Comparison_Operators](about_Comparison_Operators.md)+- [about_Break](about_Break.md) +- [about_Continue](about_Continue.md) - [about_Do](about_Do.md) - [about_Foreach](about_Foreach.md) - [about_For](about_For.md) |
Microsoft.PowerShell.Management | Copy Item (7.1) | https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/7.1/Microsoft.PowerShell.Management/Copy-Item.md | external help file: Microsoft.PowerShell.Commands.Management.dll-Help.xml Locale: en-US Module Name: Microsoft.PowerShell.Management Previously updated : 08/25/2020 Last updated : 01/18/2022 online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.management/copy-item?view=powershell-7.1&WT.mc_id=ps-gethelp schema: 2.0.0 Title: Copy-Item Copy-Item -Path "C:\Logfiles\*" -Destination "C:\Drawings" -Recurse > For example: > > `Copy-Item -Path "C:\Logfiles" -Destination "C:\Drawings" -Recurse`+> +> If the path `C:\Drawings` does not exist the cmdlet copies all the files from the `Logfiles` folder +> into a single file `C:\Drawings`. ### Example 3: Copy directory and contents to a new directory |
Microsoft.PowerShell.Management | New Psdrive (7.1) | https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/7.1/Microsoft.PowerShell.Management/New-PSDrive.md | external help file: Microsoft.PowerShell.Commands.Management.dll-Help.xml Locale: en-US Module Name: Microsoft.PowerShell.Management Previously updated : 10/22/2019 Last updated : 01/18/2022 online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.management/new-psdrive?view=powershell-7.1&WT.mc_id=ps-gethelp schema: 2.0.0 Title: New-PSDrive Title: New-PSDrive # New-PSDrive ## Synopsis-Creates temporary and persistent mapped network drives. +Creates temporary and persistent drives that are associated with a location in an item data store. ## Syntax |
Microsoft.PowerShell.Core | About Foreach (7.2) | https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/7.2/Microsoft.PowerShell.Core/About/about_Foreach.md | --- description: Describes a language command you can use to traverse all the items in a collection of items. Locale: en-US Previously updated : 02/27/2019 Last updated : 01/18/2022 online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.core/about/about_foreach?view=powershell-7.2&WT.mc_id=ps-gethelp schema: 2.0.0 Title: about Foreach collection of items. ## Long description -The `Foreach` statement (also known as a `Foreach` loop) is a language construct +The `foreach` statement (also known as a `foreach` loop) is a language construct for stepping through (iterating) a series of values in a collection of items. The simplest and most typical type of collection to traverse is an array.-Within a `Foreach` loop, it is common to run one or more commands against each +Within a `foreach` loop, it is common to run one or more commands against each item in an array. ## Syntax -The following shows the `ForEach` syntax: +The following shows the `foreach` syntax: ``` foreach ($<item> in $<collection>){<statement list>} ``` -The part of the `ForEach` statement enclosed in parenthesis represents a +The part of the `foreach` statement enclosed in parenthesis represents a variable and a collection to iterate. PowerShell creates the variable-`$<item>` automatically when the `Foreach` loop runs. Prior to each +`$<item>` automatically when the `foreach` loop runs. Prior to each iteration through the loop, the variable is set to a value in the collection.-The block following a `Foreach` statement `{<statement list>}` contains a set +The block following a `foreach` statement `{<statement list>}` contains a set of commands to execute against each item in a collection. ### Examples -For example, the `Foreach` loop in the following example displays the values +For example, the `foreach` loop in the following example displays the values in the `$letterArray` array. ```powershell foreach ($letter in $letterArray) ``` In this example, the `$letterArray` array is created and initialized with the-string values `"a"`, `"b"`, `"c"`, and `"d"`. The first time the `Foreach` +string values `"a"`, `"b"`, `"c"`, and `"d"`. The first time the `foreach` statement runs, it sets the `$letter` variable equal to the first item in `$letterArray` (`"a"`). Then, it uses the `Write-Host` cmdlet to display the letter a. The next time through the loop, `$letter` is set to `"b"`, and so-on. After the `Foreach` loop displays the letter d, PowerShell exits +on. After the `foreach` loop displays the letter d, PowerShell exits the loop. -The entire `Foreach` statement must appear on a single line to run it as a -command at the PowerShell command prompt. The entire `Foreach` statement does -not have to appear on a single line if you place the command in a .ps1 script -file instead. --`Foreach` statements can also be used together with cmdlets that return a +`foreach` statements can also be used together with cmdlets that return a collection of items. In the following example, the Foreach statement steps through the list of items that is returned by the `Get-ChildItem` cmdlet. foreach ($file in Get-ChildItem) } ``` -You can refine the example by using an `If` statement to limit the results -that are returned. In the following example, the `Foreach` statement performs -the same looping operation as the previous example, but it adds an `If` +You can refine the example by using an `if` statement to limit the results +that are returned. In the following example, the `foreach` statement performs +the same looping operation as the previous example, but it adds an `if` statement to limit the results to files that are greater than 100 kilobytes (KB): foreach ($file in Get-ChildItem) } ``` -In this example, the `Foreach` loop uses a property of the `$file` variable to +In this example, the `foreach` loop uses a property of the `$file` variable to perform a comparison operation (`$file.length -gt 100KB`). The `$file` variable contains all the properties in the object that is returned by the `Get-ChildItem` cmdlet. Therefore, you can return more than just a file name. foreach ($file in Get-ChildItem) In this example, you are not limited to running a single command in a statement list. -You can also use a variable outside a `Foreach` loop and increment the +You can also use a variable outside a `foreach` loop and increment the variable inside the loop. The following example counts files over 100 KB in size: else { In the preceding example, the `$i` variable is set to `0` outside the loop, and the variable is incremented inside the loop for each file that is found-that is larger than 100 KB. When the loop exits, an `If` statement evaluates +that is larger than 100 KB. When the loop exits, an `if` statement evaluates the value of `$i` to display a count of all the files over 100 KB. Or, it displays a message stating that no files over 100 KB were found. function Get-FunctionPosition { $filesToProcess = if ($_ -is [System.IO.FileSystemInfo]) { $_ } else {- $filesToProcess = Get-Item -Path $Path + Get-Item -Path $Path } $parser = [System.Management.Automation.Language.Parser] foreach ($item in $filesToProcess) { function Get-FunctionPosition { [about_If](about_If.md) [ForEach-Object](xref:Microsoft.PowerShell.Core.ForEach-Object)- |
Microsoft.PowerShell.Core | About While (7.2) | https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/7.2/Microsoft.PowerShell.Core/About/about_While.md | --- description: Describes a language statement that you can use to run a command block based on the results of a conditional test. Locale: en-US Previously updated : 06/10/2021 Last updated : 01/18/2022 online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.core/about/about_while?view=powershell-7.2&WT.mc_id=ps-gethelp schema: 2.0.0 Title: about While the results of a conditional test. ## Long description -The `While` statement (also known as a `While` loop) is a language construct +The `while` statement (also known as a `while` loop) is a language construct for creating a loop that runs commands in a command block as long as a-conditional test evaluates to true. The `While` statement is easier to +conditional test evaluates to true. The `while` statement is easier to construct than a For statement because its syntax is less complicated. In addition, it is more flexible than the Foreach statement because you specify a-conditional test in the `While` statement to control how many times the loop +conditional test in the `while` statement to control how many times the loop runs. The following shows the While statement syntax: The following shows the While statement syntax: while (<condition>){<statement list>} ``` -When you run a While statement, PowerShell evaluates the `<condition>` section +When you run a `while` statement, PowerShell evaluates the `<condition>` section of the statement before entering the `<statement list>` section. The condition portion of the statement resolves to either true or false. As long as the condition remains true, PowerShell reruns the `<statement list>` section. For more information about how booleans are evaluated, see [about_Booleans](about_Booleans.md). The `<statement list>` section of the statement contains one or more commands-that are run each time the loop is entered or repeated. +that are run each time the loop is entered or repeated. The `<statement list>` +can contain any valid PowerShell statements, including the `break` and +`continue` keywords. -For example, the following While statement displays the numbers 1 through 3 if +For example, the following `while` statement displays the numbers 1 through 3 if the `$val` variable has not been created or if the `$val` variable has been created and initialized to 0. the second command that writes the value of `$val` to the console. ## See also - [about_Comparison_Operators](about_Comparison_Operators.md)+- [about_Break](about_Break.md) +- [about_Continue](about_Continue.md) - [about_Do](about_Do.md) - [about_Foreach](about_Foreach.md) - [about_For](about_For.md) |
Microsoft.PowerShell.Management | Copy Item (7.2) | https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/7.2/Microsoft.PowerShell.Management/Copy-Item.md | external help file: Microsoft.PowerShell.Commands.Management.dll-Help.xml Locale: en-US Module Name: Microsoft.PowerShell.Management Previously updated : 08/25/2020 Last updated : 01/18/2022 online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.management/copy-item?view=powershell-7.2&WT.mc_id=ps-gethelp schema: 2.0.0 Title: Copy-Item Copy-Item -Path "C:\Logfiles\*" -Destination "C:\Drawings" -Recurse > For example: > > `Copy-Item -Path "C:\Logfiles" -Destination "C:\Drawings" -Recurse`+> +> If the path `C:\Drawings` does not exist the cmdlet copies all the files from the `Logfiles` folder +> into a single file `C:\Drawings`. ### Example 3: Copy directory and contents to a new directory |
Microsoft.PowerShell.Management | New Psdrive (7.2) | https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/7.2/Microsoft.PowerShell.Management/New-PSDrive.md | external help file: Microsoft.PowerShell.Commands.Management.dll-Help.xml Locale: en-US Module Name: Microsoft.PowerShell.Management Previously updated : 10/22/2019 Last updated : 01/18/2022 online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.management/new-psdrive?view=powershell-7.2&WT.mc_id=ps-gethelp schema: 2.0.0 Title: New-PSDrive Title: New-PSDrive # New-PSDrive ## Synopsis-Creates temporary and persistent mapped network drives. +Creates temporary and persistent drives that are associated with a location in an item data store. ## Syntax credentials. [Get-PSDrive](Get-PSDrive.md) [Remove-PSDrive](Remove-PSDrive.md)- |
Microsoft.PowerShell.Core | About Foreach (7.3) | https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/7.3/Microsoft.PowerShell.Core/About/about_Foreach.md | --- description: Describes a language command you can use to traverse all the items in a collection of items. Locale: en-US Previously updated : 02/27/2019 Last updated : 01/18/2022 online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.core/about/about_foreach?view=powershell-7.3&WT.mc_id=ps-gethelp schema: 2.0.0 Title: about Foreach collection of items. ## Long description -The `Foreach` statement (also known as a `Foreach` loop) is a language construct +The `foreach` statement (also known as a `foreach` loop) is a language construct for stepping through (iterating) a series of values in a collection of items. The simplest and most typical type of collection to traverse is an array.-Within a `Foreach` loop, it is common to run one or more commands against each +Within a `foreach` loop, it is common to run one or more commands against each item in an array. ## Syntax -The following shows the `ForEach` syntax: +The following shows the `foreach` syntax: ``` foreach ($<item> in $<collection>){<statement list>} ``` -The part of the `ForEach` statement enclosed in parenthesis represents a +The part of the `foreach` statement enclosed in parenthesis represents a variable and a collection to iterate. PowerShell creates the variable-`$<item>` automatically when the `Foreach` loop runs. Prior to each +`$<item>` automatically when the `foreach` loop runs. Prior to each iteration through the loop, the variable is set to a value in the collection.-The block following a `Foreach` statement `{<statement list>}` contains a set +The block following a `foreach` statement `{<statement list>}` contains a set of commands to execute against each item in a collection. ### Examples -For example, the `Foreach` loop in the following example displays the values +For example, the `foreach` loop in the following example displays the values in the `$letterArray` array. ```powershell foreach ($letter in $letterArray) ``` In this example, the `$letterArray` array is created and initialized with the-string values `"a"`, `"b"`, `"c"`, and `"d"`. The first time the `Foreach` +string values `"a"`, `"b"`, `"c"`, and `"d"`. The first time the `foreach` statement runs, it sets the `$letter` variable equal to the first item in `$letterArray` (`"a"`). Then, it uses the `Write-Host` cmdlet to display the letter a. The next time through the loop, `$letter` is set to `"b"`, and so-on. After the `Foreach` loop displays the letter d, PowerShell exits +on. After the `foreach` loop displays the letter d, PowerShell exits the loop. -The entire `Foreach` statement must appear on a single line to run it as a -command at the PowerShell command prompt. The entire `Foreach` statement does -not have to appear on a single line if you place the command in a .ps1 script -file instead. --`Foreach` statements can also be used together with cmdlets that return a +`foreach` statements can also be used together with cmdlets that return a collection of items. In the following example, the Foreach statement steps through the list of items that is returned by the `Get-ChildItem` cmdlet. foreach ($file in Get-ChildItem) } ``` -You can refine the example by using an `If` statement to limit the results -that are returned. In the following example, the `Foreach` statement performs -the same looping operation as the previous example, but it adds an `If` +You can refine the example by using an `if` statement to limit the results +that are returned. In the following example, the `foreach` statement performs +the same looping operation as the previous example, but it adds an `if` statement to limit the results to files that are greater than 100 kilobytes (KB): foreach ($file in Get-ChildItem) } ``` -In this example, the `Foreach` loop uses a property of the `$file` variable to +In this example, the `foreach` loop uses a property of the `$file` variable to perform a comparison operation (`$file.length -gt 100KB`). The `$file` variable contains all the properties in the object that is returned by the `Get-ChildItem` cmdlet. Therefore, you can return more than just a file name. foreach ($file in Get-ChildItem) In this example, you are not limited to running a single command in a statement list. -You can also use a variable outside a `Foreach` loop and increment the +You can also use a variable outside a `foreach` loop and increment the variable inside the loop. The following example counts files over 100 KB in size: else { In the preceding example, the `$i` variable is set to `0` outside the loop, and the variable is incremented inside the loop for each file that is found-that is larger than 100 KB. When the loop exits, an `If` statement evaluates +that is larger than 100 KB. When the loop exits, an `if` statement evaluates the value of `$i` to display a count of all the files over 100 KB. Or, it displays a message stating that no files over 100 KB were found. function Get-FunctionPosition { $filesToProcess = if ($_ -is [System.IO.FileSystemInfo]) { $_ } else {- $filesToProcess = Get-Item -Path $Path + Get-Item -Path $Path } $parser = [System.Management.Automation.Language.Parser] foreach ($item in $filesToProcess) { function Get-FunctionPosition { [about_If](about_If.md) [ForEach-Object](xref:Microsoft.PowerShell.Core.ForEach-Object)- |
Microsoft.PowerShell.Core | About Pwsh (7.3) | https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/7.3/Microsoft.PowerShell.Core/About/about_Pwsh.md | --- description: Explains how to use the `pwsh` command-line interface. Displays the command-line parameters and describes the syntax. Locale: en-US Previously updated : 10/22/2020 Last updated : 01/18/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.1&WT.mc_id=ps-gethelp schema: 2.0.0 Example: `pwsh -NoExit -Command Get-Date` ### -NoLogo | -nol -Hides the copyright banner at startup of interactive sessions. +Hides the banner at startup of interactive sessions. ### -NonInteractive | -noni |
Microsoft.PowerShell.Core | About While (7.3) | https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/7.3/Microsoft.PowerShell.Core/About/about_While.md | --- description: Describes a language statement that you can use to run a command block based on the results of a conditional test. Locale: en-US Previously updated : 06/10/2021 Last updated : 01/18/2022 online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.core/about/about_while?view=powershell-7.3&WT.mc_id=ps-gethelp schema: 2.0.0 Title: about While the results of a conditional test. ## Long description -The `While` statement (also known as a `While` loop) is a language construct +The `while` statement (also known as a `while` loop) is a language construct for creating a loop that runs commands in a command block as long as a-conditional test evaluates to true. The `While` statement is easier to +conditional test evaluates to true. The `while` statement is easier to construct than a For statement because its syntax is less complicated. In addition, it is more flexible than the Foreach statement because you specify a-conditional test in the `While` statement to control how many times the loop +conditional test in the `while` statement to control how many times the loop runs. The following shows the While statement syntax: The following shows the While statement syntax: while (<condition>){<statement list>} ``` -When you run a While statement, PowerShell evaluates the `<condition>` section +When you run a `while` statement, PowerShell evaluates the `<condition>` section of the statement before entering the `<statement list>` section. The condition portion of the statement resolves to either true or false. As long as the condition remains true, PowerShell reruns the `<statement list>` section. For more information about how booleans are evaluated, see [about_Booleans](about_Booleans.md). The `<statement list>` section of the statement contains one or more commands-that are run each time the loop is entered or repeated. +that are run each time the loop is entered or repeated. The `<statement list>` +can contain any valid PowerShell statements, including the `break` and +`continue` keywords. -For example, the following While statement displays the numbers 1 through 3 if +For example, the following `while` statement displays the numbers 1 through 3 if the `$val` variable has not been created or if the `$val` variable has been created and initialized to 0. the second command that writes the value of `$val` to the console. ## See also - [about_Comparison_Operators](about_Comparison_Operators.md)+- [about_Break](about_Break.md) +- [about_Continue](about_Continue.md) - [about_Do](about_Do.md) - [about_Foreach](about_Foreach.md) - [about_For](about_For.md) |
Microsoft.PowerShell.Core | Invoke Command (7.3) | https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/7.3/Microsoft.PowerShell.Core/Invoke-Command.md | Runs commands on local and remote computers. ### InProcess (Default) ```-Invoke-Command [-ScriptBlock] <ScriptBlock> [-NoNewScope] [-InputObject <PSObject>] - [-ArgumentList <Object[]>] [<CommonParameters>] +Invoke-Command [-StrictMode <Version>] [-ScriptBlock] <ScriptBlock> [-NoNewScope] + [-InputObject <PSObject>] [-ArgumentList <Object[]>] [<CommonParameters>] ``` ### FilePathRunspace Accept pipeline input: False Accept wildcard characters: False ``` +### -StrictMode ++The **StrictMode** parameter sets the provided version for the process. Once the process completes, +the **StrictMode** version is set back to what it was before the `Invoke-Command`. ++This is an experimental feature added in PowerShell 7.3-preview.2. You must enable the +**PSStrictModeAssignment** experiment to use this parameter. ++```yaml +Type: System.Version +Parameter Sets: InProcess +Aliases: ++Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -Subsystem Specifies the SSH subsystem used for the new **PSSession**. |
Microsoft.PowerShell.Management | Copy Item (7.3) | https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/7.3/Microsoft.PowerShell.Management/Copy-Item.md | Copy-Item -Path "C:\Logfiles\*" -Destination "C:\Drawings" -Recurse > For example: > > `Copy-Item -Path "C:\Logfiles" -Destination "C:\Drawings" -Recurse`+> +> If the path `C:\Drawings` does not exist the cmdlet copies all the files from the `Logfiles` folder +> into a single file `C:\Drawings`. ### Example 3: Copy directory and contents to a new directory |
Microsoft.PowerShell.Management | New Psdrive (7.3) | https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/7.3/Microsoft.PowerShell.Management/New-PSDrive.md | external help file: Microsoft.PowerShell.Commands.Management.dll-Help.xml Locale: en-US Module Name: Microsoft.PowerShell.Management Previously updated : 10/22/2019 Last updated : 01/18/2022 online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.management/new-psdrive?view=powershell-7.3&WT.mc_id=ps-gethelp schema: 2.0.0 Title: New-PSDrive Title: New-PSDrive # New-PSDrive ## Synopsis-Creates temporary and persistent mapped network drives. +Creates temporary and persistent drives that are associated with a location in an item data store. ## Syntax |
Microsoft.PowerShell.Utility | Start Sleep (7.3) | https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/7.3/Microsoft.PowerShell.Utility/Start-Sleep.md | external help file: Microsoft.PowerShell.Commands.Utility.dll-Help.xml Locale: en-US Module Name: Microsoft.PowerShell.Utility Previously updated : 04/10/2019 Last updated : 01/18/2022 online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/start-sleep?view=powershell-7.3&WT.mc_id=ps-gethelp schema: 2.0.0 Title: Start-Sleep Start-Sleep [-Seconds] <Double> [<CommonParameters>] Start-Sleep -Milliseconds <Int32> [<CommonParameters>] ``` +### FromTimeSpan ++``` +Start-Sleep -Duration <TimeSpan> [<CommonParameters>] +``` + ## Description The `Start-Sleep` cmdlet suspends the activity in a script or session for the specified period of This example makes all the commands in the session sleep for one and one-half of Start-Sleep -Seconds 1.5 ``` +### Example 3: Sleep commands using a **TimeSpan** ++This example makes all the commands in the session sleep for 30 seconds. ++```powershell +Start-Sleep -Duration (New-TimeSpan -Seconds 30) +``` + ## Parameters +### -Duration ++Uses a **TimeSpan** object to specify how long the resource sleeps in milliseconds. The value must +not be a negative **TimeSpan** and must not exceed `[int]::MaxValue` milliseconds. ++```yaml +Type: System.TimeSpan +Parameter Sets: FromTimeSpan +Aliases: ts ++Required: True +Position: Named +Default value: None +Accept pipeline input: True (ByPropertyName, ByValue) +Accept wildcard characters: False +``` + ### -Milliseconds Specifies how long the resource sleeps in milliseconds. The parameter can be abbreviated as **m**. 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](../Microsoft.PowerShell.Core/About/about_CommonParameters.md).+-WarningAction, and -WarningVariable. For more information, see +[about_CommonParameters](../Microsoft.PowerShell.Core/About/about_CommonParameters.md). ## Inputs This cmdlet does not return any output. [Thread.Sleep Method](/dotnet/api/system.threading.thread.sleep). ## Related links- |
developer | Formatstring Element For Listitem For Listcontrol Format | https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/docs-conceptual/developer/format/formatstring-element-for-listitem-for-listcontrol-format.md | property. ```xml <ListItem> <PropertyName>StartTime</PropertyName>- <FormatString>{0:MMM} (0:DD) (0:HH):(0:MM)</FormatString> + <FormatString>{0:MMM} {0:DD} {0:HH}:{0:MM}</FormatString> </ListItem> ``` |
developer | Formatstring Element For Tablecolumnitem For Tablecontrol Format | https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/docs-conceptual/developer/format/formatstring-element-for-tablecolumnitem-for-tablecontrol-format.md | property. ```xml <TableColumnItem> <PropertyName>StartTime</PropertyName>- <FormatString>{0:MMM} (0:DD) (0:HH):(0:MM)</FormatString> + <FormatString>{0:MMM} {0:DD} {0:HH}:{0:MM}</FormatString> </TableColumnItem> ``` |
developer | Formatstring Element For Wideitem For Widecontrol Format | https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/docs-conceptual/developer/format/formatstring-element-for-wideitem-for-widecontrol-format.md | property. ```xml <WideItem> <PropertyName>StartTime</PropertyName>- <FormatString>{0:MMM} (0:DD) (0:HH):(0:MM)</FormatString> + <FormatString>{0:MMM} {0:DD} {0:HH}:{0:MM}</FormatString> </WideItem> ``` |
learn | Experimental Features | https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/docs-conceptual/learn/experimental-features.md | --- description: Lists the currently available experimental features and how to use them. Previously updated : 11/08/2021 Last updated : 01/18/2022 Title: Using Experimental Features in PowerShell --- # Using Experimental Features in PowerShell Legend | PSAnsiRenderingFileInfo | | | ✔️ | ✔️ | | PSLoadAssemblyFromNativeCode | | | ✔️ | ✔️ | | PSCleanBlock | | | | ✔️ |+| PSStrictModeAssignment | | | | ✔️ | ## Microsoft.PowerShell.Utility.PSManageBreakpointsInRunspace variables must use `{}` around the variable name like: `${x?}?.propertyName` or > This feature has moved out of the experimental phase and is a mainstream feature in PowerShell 7.1 > and higher. +## PSStrictModeAssignment ++PowerShell 7.3-preview.2 adds the **StrictMode** parameter to `Invoke-Command` to allow specifying +strict mode when invoking command locally. The **StrictMode** parameter sets the provided version +for the process. Once the process completes, the **StrictMode** version is set back to what it was +before the `Invoke-Command`. ++This feature does not support asynchronous jobs on remote machines. + ## PSUnixFileStat This feature provides more Unix-like file listings by including data from the Unix **stat** API. It |
learn | 01 Discover Powershell | https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/docs-conceptual/learn/tutorials/01-discover-powershell.md | well. Verb and noun is something you can filter on as well. Such filtering targe command's name. - **Filter on verb**. The verb part of a command's name is the leftmost part. In the command- `Get-Process`, the verb part is `Get`. To filter on th verb part, specify `-Verb` as a parameter + `Get-Process`, the verb part is `Get`. To filter on the verb part, specify `-Verb` as a parameter like so: ```powershell like what type it operates on and what other similar commands operate on that sa -------- ``` - What you're getting back, is a the types returned by the command `Get-Command`. At this point you + What you're getting back, are the types returned by the command `Get-Command`. At this point you can now find out what other command also operates on these types. 1. Run the command `Get-Command`: |
whats-new | What S New In Powershell 73 | https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/docs-conceptual/whats-new/What-s-New-in-PowerShell-73.md | --- Title: What's New in PowerShell 7.3-preview.1 description: New features and changes released in PowerShell 7.3-preview.1 Previously updated : 12/16/2021 Last updated : 01/18/2022 --- # What's New in PowerShell 7.3 For a complete list of changes, see the [Change Log][CHANGELOG] in the GitHub re > [!NOTE] > There is a known issue in 7.3.0-preview.1 - Alpine Linux packages are missing the-> `powershell.config.json` file, causing experimental features to be disabled by default. For details, -> see Issue #16636. +> `powershell.config.json` file, causing experimental features to be disabled by default. For +> details, see Issue #16636. PowerShell 7.3 introduces the following experimental features: - [PSCleanBlock][exp-clean] - Adds `clean` block to script block as a peer to `begin`, `process`, and `end` to allow easy resource cleanup+- [PSStrictModeAssignment][strict] - Adds the **StrictMode** parameter to `Invoke-Command` to allow + specifying strict mode when invoking command locally. For more information about the Experimental Features, see [Using Experimental Features][exp]. For more information about the Experimental Features, see [Using Experimental Fe [CHANGELOG]: https://github.com/PowerShell/PowerShell/releases/tag/v7.3.0-preview.1 [exp-clean]: ../learn/experimental-features.md#pscleanblock+[strict]: ../learn/experimental-features.md#psstrictmodeassignment |
windows-powershell | Installing Windows Powershell | https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/docs-conceptual/windows-powershell/install/Installing-Windows-PowerShell.md | --- description: This article explains how to install Windows PowerShell on various versions of Windows. Previously updated : 10/22/2021 Last updated : 01/18/2022 Title: Installing Windows PowerShell --- # Installing Windows PowerShell here are the original version, as released, with no updates. | Version | Location | | ---------------- | ------------------------------------------------------------------------------------------------------------------------------ |-| Windows 10, 11 | Click left lower corner Windows icon, start typing PowerShell | +| Windows 10, 11 | Click Windows icon (lower left corner for Windows 10, lower center for Windows 11), start typing PowerShell | | Windows 8.1, 8.0 | On the start screen, start typing PowerShell.<br/>If on desktop, click left lower corner Windows icon, start typing PowerShell | | Windows 7 SP1 | Click left lower corner Windows icon, on the search box start typing PowerShell | PowerShell. If you need to update your existing version of PowerShell, in Windows, use the following table to locate the installer for the version of PowerShell you want to update to. -| Windows | PS 3.0 | PS 4.0 | PS 5.0 | PS 5.1 | -| ---------------------------------------------- | ------------------------------------------------------------------- | ------------------------------------------------------------------- | ------------------------------------------------------------------- | ------------------------------------------------------------------- | -| Windows 10 (see Note1)<br/>Windows Server 2016 | - | - | - | installed | -| Windows 8.1<br/>Windows Server 2012 R2 | - | installed | [WMF 5.0](https://www.microsoft.com/download/details.aspx?id=50395) | [WMF 5.1](https://www.microsoft.com/download/details.aspx?id=54616) | -| Windows 8<br/>Windows Server 2012 | installed | [WMF 4.0](https://www.microsoft.com/download/details.aspx?id=40855) | [WMF 5.0](https://www.microsoft.com/download/details.aspx?id=50395) | [WMF 5.1](https://www.microsoft.com/download/details.aspx?id=54616) | -| Windows 7 SP1<br/>Windows Server 2008 R2 SP1 | [WMF 3.0](https://www.microsoft.com/download/details.aspx?id=34595) | [WMF 4.0](https://www.microsoft.com/download/details.aspx?id=40855) | [WMF 5.0](https://www.microsoft.com/download/details.aspx?id=50395) | [WMF 5.1](https://www.microsoft.com/download/details.aspx?id=54616) | +| Windows | PS 3.0 | PS 4.0 | PS 5.0 | PS 5.1 | +| ---------------------------------------------- | :----------------: | :----------------: | :----------------: | :----------------: | +| Windows 11 <br/>Windows Server 2022 | - | - | - | installed | +| Windows 10 (see Note1)<br/>Windows Server 2016 | - | - | - | installed | +| Windows 8.1<br/>Windows Server 2012 R2 | - | installed | [WMF 5.0][WMF 5.0] | [WMF 5.1][WMF 5.1] | +| Windows 8<br/>Windows Server 2012 | installed | [WMF 4.0][WMF 4.0] | [WMF 5.0][WMF 5.0] | [WMF 5.1][WMF 5.1] | +| Windows 7 SP1<br/>Windows Server 2008 R2 SP1 | [WMF 3.0][WMF 3.0] | [WMF 4.0][WMF 4.0] | [WMF 5.0][WMF 5.0] | [WMF 5.1][WMF 5.1] | > [!NOTE] > On the initial release of Windows 10, with automatic updates enabled, PowerShell gets updated from Otherwise, what you might need is [Windows PowerShell System Requirements](Windows-PowerShell-System-Requirements.md) [Starting Windows PowerShell](../Starting-Windows-PowerShell.md)++<!-- link refs --> ++[WMF 3.0]: https://www.microsoft.com/download/details.aspx?id=34595 +[WMF 4.0]: https://www.microsoft.com/download/details.aspx?id=40855 +[WMF 5.0]: https://www.microsoft.com/download/details.aspx?id=50395 +[WMF 5.1]: https://www.microsoft.com/download/details.aspx?id=54616 |