From b16728daeeaf3cd83a5169b91a675f081db64d69 Mon Sep 17 00:00:00 2001 From: Bobby Reed Date: Wed, 25 Apr 2018 12:52:38 -0400 Subject: [PATCH 1/2] Fixing issue with faulty links from issue (2322) --- .../About/about_windows_powershell_5.1.md | 9 +++++---- wmf/5.1/scenarios-features.md | 9 +++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/reference/5.1/Microsoft.PowerShell.Core/About/about_windows_powershell_5.1.md b/reference/5.1/Microsoft.PowerShell.Core/About/about_windows_powershell_5.1.md index d4a9c3b75d75..f84694156335 100644 --- a/reference/5.1/Microsoft.PowerShell.Core/About/about_windows_powershell_5.1.md +++ b/reference/5.1/Microsoft.PowerShell.Core/About/about_windows_powershell_5.1.md @@ -59,10 +59,11 @@ Starting with version 5.1, PowerShell is available in different editions which d editions of Windows such as Nano Server and Windows IoT. **Learn more about using PowerShell Editions** -- [Determine running edition of PowerShell]() -- [Declare a module's compatibility to specific PowerShell versions]() -- [Filter Get-Module results by CompatiblePSEditions]() -- [Prevent script execution unless run on a compatible edition of PowerShell]() + +- [Determine running edition of PowerShell using $PSVersionTable](/powershell/module/microsoft.powershell.core/about/about_automatic_variables) +- [Filter Get-Module results by CompatiblePSEditions using PSEdition parameter](/powershell/module/microsoft.powershell.core/get-module) +- [Prevent script execution unless run on a compatible edition of PowerShell](/powershell/gallery/psget/script/scriptwithpseditionsupport) +- [Declare a module's compatibility to specific PowerShell versions](/powershell/gallery/psget/module/modulewithpseditionsupport) ### Catalog Cmdlets diff --git a/wmf/5.1/scenarios-features.md b/wmf/5.1/scenarios-features.md index 496d44819232..7a3722b53704 100644 --- a/wmf/5.1/scenarios-features.md +++ b/wmf/5.1/scenarios-features.md @@ -17,10 +17,11 @@ Starting with version 5.1, PowerShell is available in different editions which d - **Core Edition:** Built on .NET Core and provides compatibility with scripts and modules targeting versions of PowerShell running on reduced footprint editions of Windows such as Nano Server and Windows IoT. **Learn more about using PowerShell Editions** -- [Determine running edition of PowerShell]() -- [Declare a module's compatibility to specific PowerShell versions]() -- [Filter Get-Module results by CompatiblePSEditions]() -- [Prevent script execution unless run on a compatible edition of PowerShell]() + +- [Determine running edition of PowerShell using $PSVersionTable](/powershell/module/microsoft.powershell.core/about/about_automatic_variables) +- [Filter Get-Module results by CompatiblePSEditions using PSEdition parameter](/powershell/module/microsoft.powershell.core/get-module) +- [Prevent script execution unless run on a compatible edition of PowerShell](/powershell/gallery/psget/script/scriptwithpseditionsupport) +- [Declare a module's compatibility to specific PowerShell versions](/powershell/gallery/psget/module/modulewithpseditionsupport) ## Catalog Cmdlets From c6ea429a97ab9c6661f1d9416615f06ddf252845 Mon Sep 17 00:00:00 2001 From: Bobby Reed Date: Wed, 25 Apr 2018 13:51:40 -0400 Subject: [PATCH 2/2] Trying smaller pull requests to test Script Automation --- .../About/about_Aliases.md | 7 +- .../About/about_Arithmetic_Operators.md | 23 ++- .../About/about_Arrays.md | 11 +- .../About/about_Assignment_Operators.md | 3 +- .../About/about_Automatic_Variables.md | 8 +- .../About/about_Break.md | 3 +- .../About/about_Command_Precedence.md | 7 +- .../About/about_Command_Syntax.md | 3 +- .../About/about_Comment_Based_Help.md | 32 ++-- .../About/about_CommonParameters.md | 38 ++--- .../About/about_Comparison_Operators.md | 142 +++++++++--------- .../About/about_Continue.md | 3 +- .../About/about_Core_Commands.md | 3 +- .../About/about_Data_Sections.md | 11 +- .../About/about_Debuggers.md | 111 ++++++-------- .../About/about_Do.md | 15 +- .../About/about_Environment_Variables.md | 9 +- .../About/about_Eventlogs.md | 11 +- .../About/about_Execution_Policies.md | 16 +- .../About/about_For.md | 6 +- .../About/about_Foreach.md | 3 +- .../About/about_Format.ps1xml.md | 25 ++- .../About/about_Functions.md | 31 ++-- .../About/about_Functions_Advanced.md | 5 +- .../About/about_Functions_Advanced_Methods.md | 3 +- 25 files changed, 255 insertions(+), 274 deletions(-) diff --git a/reference/3.0/Microsoft.PowerShell.Core/About/about_Aliases.md b/reference/3.0/Microsoft.PowerShell.Core/About/about_Aliases.md index a78090e0193a..ecf93d074e5d 100644 --- a/reference/3.0/Microsoft.PowerShell.Core/About/about_Aliases.md +++ b/reference/3.0/Microsoft.PowerShell.Core/About/about_Aliases.md @@ -1,11 +1,10 @@ ---- +--- ms.date: 11/27/2017 schema: 2.0.0 locale: en-us keywords: powershell,cmdlet title: about_Aliases --- - # About Aliases ## SHORT DESCRIPTION @@ -148,7 +147,7 @@ Get-Alias returns only one type of object, an AliasInfo object include a hyphen, such as "cd" are displayed in the following format: ```powershell -PS C:\> Get-Alias ac +PS> Get-Alias ac CommandType Name Version Source ----------- ---- ------- ------ @@ -177,7 +176,7 @@ For example, the following command creates the syslog function. This function represents the `Get-Eventlog -LogName System` command: ```powershell -function Get-SystemEventlog {Get-Eventlog -LogName System} +function Get-SystemEventlog {Get-EventLog -LogName System} Set-Alias -Name syslog -Value Get-SystemEventlog ``` diff --git a/reference/3.0/Microsoft.PowerShell.Core/About/about_Arithmetic_Operators.md b/reference/3.0/Microsoft.PowerShell.Core/About/about_Arithmetic_Operators.md index f86b5c3783ee..e914c6f46864 100644 --- a/reference/3.0/Microsoft.PowerShell.Core/About/about_Arithmetic_Operators.md +++ b/reference/3.0/Microsoft.PowerShell.Core/About/about_Arithmetic_Operators.md @@ -1,11 +1,10 @@ ---- +--- ms.date: 11/27/2017 schema: 2.0.0 locale: en-us keywords: powershell,cmdlet title: about_Arithmetic_Operators --- - # About Arithmetic Operators ## SHORT DESCRIPTION @@ -364,7 +363,7 @@ The following examples show how to use the arithmetic operators in expressions with PowerShell commands: ```powershell -(get-date) + (new-timespan -day 1) +(Get-Date) + (New-TimeSpan -Days 1) ``` The parenthesis operator forces the evaluation of the `get-date` cmdlet and @@ -456,7 +455,7 @@ For example, the binary complement of 0 is -1, the maximum unsigned integer (0xffffffff), and the binary complement of -1 is 0. ```powershell -PS C:\> -bNot 10 +PS> -bNot 10 -11 ``` @@ -509,11 +508,11 @@ right operand determine how many bits of the left operand are shifted. ## SEE ALSO -* [about_arrays](about_Arrays.md) -* [about_assignment_operators](about_Assignment_Operators.md) -* [about_comparison_operators](about_Comparison_Operators.md) -* [about_hash_tables](about_Hash_Tables.md) -* [about_operators](about_Operators.md) -* [about_variables](about_Variables.md) -* [Get-Date](../../Microsoft.PowerShell.Utility/Get-Date.md) -* [New-TimeSpan](../../Microsoft.PowerShell.Utility/New-TimeSpan.md) \ No newline at end of file +- [about_arrays](about_Arrays.md) +- [about_assignment_operators](about_Assignment_Operators.md) +- [about_comparison_operators](about_Comparison_Operators.md) +- [about_hash_tables](about_Hash_Tables.md) +- [about_operators](about_Operators.md) +- [about_variables](about_Variables.md) +- [Get-Date](../../Microsoft.PowerShell.Utility/Get-Date.md) +- [New-TimeSpan](../../Microsoft.PowerShell.Utility/New-TimeSpan.md) \ No newline at end of file diff --git a/reference/3.0/Microsoft.PowerShell.Core/About/about_Arrays.md b/reference/3.0/Microsoft.PowerShell.Core/About/about_Arrays.md index e411fc2b53a0..175aae55fb66 100644 --- a/reference/3.0/Microsoft.PowerShell.Core/About/about_Arrays.md +++ b/reference/3.0/Microsoft.PowerShell.Core/About/about_Arrays.md @@ -1,11 +1,10 @@ ---- +--- ms.date: 06/09/2017 schema: 2.0.0 locale: en-us keywords: powershell,cmdlet title: about_Arrays --- - # About Arrays # SHORT DESCRIPTION @@ -89,12 +88,12 @@ You can use the array operator to create an array of zero or one object. For example: ```powershell -PS C:\> $a = @("Hello World") -PS C:\> $a.Count +PS> $a = @("Hello World") +PS> $a.Count 1 -PS C:\> $b = @() -PS C:\> $b.Count +PS> $b = @() +PS> $b.Count 0 ``` diff --git a/reference/3.0/Microsoft.PowerShell.Core/About/about_Assignment_Operators.md b/reference/3.0/Microsoft.PowerShell.Core/About/about_Assignment_Operators.md index b19af2c9c6dc..ac0f1b34c5e6 100644 --- a/reference/3.0/Microsoft.PowerShell.Core/About/about_Assignment_Operators.md +++ b/reference/3.0/Microsoft.PowerShell.Core/About/about_Assignment_Operators.md @@ -1,10 +1,9 @@ ---- +--- ms.date: 11/27/2017 schema: 2.0.0 keywords: powershell,cmdlet title: about_Assignment_Operators --- - # About Assignment Operators ## SHORT DESCRIPTION diff --git a/reference/3.0/Microsoft.PowerShell.Core/About/about_Automatic_Variables.md b/reference/3.0/Microsoft.PowerShell.Core/About/about_Automatic_Variables.md index 17a43e1cf95d..beef82762869 100644 --- a/reference/3.0/Microsoft.PowerShell.Core/About/about_Automatic_Variables.md +++ b/reference/3.0/Microsoft.PowerShell.Core/About/about_Automatic_Variables.md @@ -1,11 +1,10 @@ ---- +--- ms.date: 12/21/2017 schema: 2.0.0 locale: en-us keywords: powershell,cmdlet title: about_Automatic_Variables --- - # About Automatic Variables ## SHORT DESCRIPTION @@ -286,13 +285,13 @@ profile in commands. For example, you can use it in a command to determine whether a profile has been created: ```powershell -test-path $profile +Test-Path $profile ``` Or, you can use it in a command to create a profile: ```powershell -new-item -type file -path $pshome -force +New-Item -ItemType file -Path $pshome -Force ``` You can also use it in a command to open the profile in Notepad: @@ -460,6 +459,7 @@ this variable can also be found in the Sender property of the PSEventArgs Contains the identifier of the current shell. ### $STACKTRACE + Contains a stack trace for the most recent error. ### $THIS diff --git a/reference/3.0/Microsoft.PowerShell.Core/About/about_Break.md b/reference/3.0/Microsoft.PowerShell.Core/About/about_Break.md index a3a67a8190fd..6b1fc476f4c8 100644 --- a/reference/3.0/Microsoft.PowerShell.Core/About/about_Break.md +++ b/reference/3.0/Microsoft.PowerShell.Core/About/about_Break.md @@ -1,11 +1,10 @@ ---- +--- ms.date: 06/09/2017 schema: 2.0.0 locale: en-us keywords: powershell,cmdlet title: about_Break --- - # About Break ## SHORT DESCRIPTION diff --git a/reference/3.0/Microsoft.PowerShell.Core/About/about_Command_Precedence.md b/reference/3.0/Microsoft.PowerShell.Core/About/about_Command_Precedence.md index 7592f0883d3b..9873216a068b 100644 --- a/reference/3.0/Microsoft.PowerShell.Core/About/about_Command_Precedence.md +++ b/reference/3.0/Microsoft.PowerShell.Core/About/about_Command_Precedence.md @@ -1,10 +1,9 @@ ---- +--- ms.date: 06/27/2017 schema: 2.0.0 keywords: powershell,cmdlet title: about_Command_Precedence --- - # About Command Precedence ## SHORT DESCRIPTION @@ -210,7 +209,7 @@ For example, if you have a function named "Map" that is hidden by an alias named "Map", use the following command to run the function. ```powershell -&(Get-Command -Name Map -Type Function) +&(Get-Command -Name Map -CommandType Function) ``` or @@ -225,7 +224,7 @@ For example, the following command saves the "Map" function in the "$myMap" variable and then uses the `Call` operator to run it. ```powershell -$myMap = (Get-Command -Name map -Type function) +$myMap = (Get-Command -Name map -CommandType function) &($myMap) ``` diff --git a/reference/3.0/Microsoft.PowerShell.Core/About/about_Command_Syntax.md b/reference/3.0/Microsoft.PowerShell.Core/About/about_Command_Syntax.md index db7f64b974ef..4416c054a296 100644 --- a/reference/3.0/Microsoft.PowerShell.Core/About/about_Command_Syntax.md +++ b/reference/3.0/Microsoft.PowerShell.Core/About/about_Command_Syntax.md @@ -1,10 +1,9 @@ ---- +--- ms.date: 06/27/2017 schema: 2.0.0 keywords: powershell,cmdlet title: about_Command_Syntax --- - # About Command Syntax # SHORT DESCRIPTION diff --git a/reference/3.0/Microsoft.PowerShell.Core/About/about_Comment_Based_Help.md b/reference/3.0/Microsoft.PowerShell.Core/About/about_Comment_Based_Help.md index dcdce243b7d4..552885d55443 100644 --- a/reference/3.0/Microsoft.PowerShell.Core/About/about_Comment_Based_Help.md +++ b/reference/3.0/Microsoft.PowerShell.Core/About/about_Comment_Based_Help.md @@ -1,4 +1,4 @@ ---- +--- ms.date: 06/09/2017 schema: 2.0.0 keywords: powershell,cmdlet @@ -515,17 +515,17 @@ or file name. .EXAMPLE -C:\PS> extension -name "File" +PS> extension -name "File" File.txt .EXAMPLE -C:\PS> extension -name "File" -extension "doc" +PS> extension -name "File" -extension "doc" File.doc .EXAMPLE -C:\PS> extension "File" "doc" +PS> extension "File" "doc" File.doc .LINK @@ -600,17 +600,17 @@ file name. Example 1 -C:\PS> extension -name "File" +PS> extension -name "File" File.txt Example 2 -C:\PS> extension -name "File" -extension "doc" +PS> extension -name "File" -extension "doc" File.doc Example 3 -C:\PS> extension "File" "doc" +PS> extension "File" "doc" File.doc RELATED LINKS @@ -664,17 +664,17 @@ file name. .EXAMPLE -C:\PS> extension -name "File" +PS> extension -name "File" File.txt .EXAMPLE -C:\PS> extension -name "File" -extension "doc" +PS> extension -name "File" -extension "doc" File.doc .EXAMPLE -C:\PS> extension "File" "doc" +PS> extension "File" "doc" File.doc .LINK @@ -726,15 +726,15 @@ None. Update-Month.ps1 does not generate any output. .EXAMPLE -C:\PS> .\Update-Month.ps1 +PS> .\Update-Month.ps1 .EXAMPLE -C:\PS> .\Update-Month.ps1 -inputpath C:\Data\January.csv +PS> .\Update-Month.ps1 -inputpath C:\Data\January.csv .EXAMPLE -C:\PS> .\Update-Month.ps1 -inputpath C:\Data\January.csv -outputPath ` +PS> .\Update-Month.ps1 -inputpath C:\Data\January.csv -outputPath ` C:\Reports\2009\January.csv #> @@ -809,15 +809,15 @@ None. Update-Month.ps1 does not generate any output. Example 1 -C:\PS> .\Update-Month.ps1 +PS> .\Update-Month.ps1 Example 2 -C:\PS> .\Update-Month.ps1 -inputpath C:\Data\January.csv +PS> .\Update-Month.ps1 -inputpath C:\Data\January.csv Example 3 -C:\PS> .\Update-Month.ps1 -inputpath C:\Data\January.csv -outputPath +PS> .\Update-Month.ps1 -inputpath C:\Data\January.csv -outputPath C:\Reports\2009\January.csv # RELATED LINKS diff --git a/reference/3.0/Microsoft.PowerShell.Core/About/about_CommonParameters.md b/reference/3.0/Microsoft.PowerShell.Core/About/about_CommonParameters.md index fcfbf4a21901..605234508e32 100644 --- a/reference/3.0/Microsoft.PowerShell.Core/About/about_CommonParameters.md +++ b/reference/3.0/Microsoft.PowerShell.Core/About/about_CommonParameters.md @@ -1,11 +1,10 @@ ---- +--- ms.date: 11/27/2017 schema: 2.0.0 locale: en-us keywords: powershell,cmdlet title: about_CommonParameters --- - # About CommonParameters ## SHORT DESCRIPTION @@ -37,22 +36,22 @@ to user data usually offer these parameters. The following list displays the common parameters. Their aliases are listed in parentheses. -* Debug (db) -* ErrorAction (ea) -* ErrorVariable (ev) -* InformationAction (infa) -* InformationVariable (iv) -* OutVariable (ov) -* OutBuffer (ob) -* PipelineVariable (pv) -* Verbose (vb) -* WarningAction (wa) -* WarningVariable (wv) +- Debug (db) +- ErrorAction (ea) +- ErrorVariable (ev) +- InformationAction (infa) +- InformationVariable (iv) +- OutVariable (ov) +- OutBuffer (ob) +- PipelineVariable (pv) +- Verbose (vb) +- WarningAction (wa) +- WarningVariable (wv) The risk mitigation parameters are: -* WhatIf (wi) -* Confirm (cf) +- WhatIf (wi) +- Confirm (cf) For more information about preference variables, type: help about_Preference_Variables @@ -127,7 +126,7 @@ Stores error messages about the command in the specified variable and in the $Error automatic variable. For more information, type the following command: ```powershell -get-help about_Automatic_Variables +Get-Help about_Automatic_Variables ``` By default, new error messages overwrite error messages that are already @@ -140,6 +139,7 @@ errors in it: ```powershell Get-Process -Id 6 -ErrorVariable a ``` + The following command adds any error messages to the $a variable: ```powershell @@ -275,9 +275,9 @@ that the results should be displayed as "Left range member * Right range member = product". ```powershell -1..10 | Foreach-Object -PipelineVariable Left -Process { $_ } | - Foreach-Object -PV Right -Process { 1..10 } | - Foreach-Object -Process { "$Left * $Right = " + ($Left*$Right) } +1..10 | ForEach-Object -PipelineVariable Left -Process { $_ } | + ForEach-Object -PipelineVariable Right -Process { 1..10 } | + ForEach-Object -Process { "$Left * $Right = " + ($Left*$Right) } ``` ```output diff --git a/reference/3.0/Microsoft.PowerShell.Core/About/about_Comparison_Operators.md b/reference/3.0/Microsoft.PowerShell.Core/About/about_Comparison_Operators.md index d8a05dd57df0..911677d507a1 100644 --- a/reference/3.0/Microsoft.PowerShell.Core/About/about_Comparison_Operators.md +++ b/reference/3.0/Microsoft.PowerShell.Core/About/about_Comparison_Operators.md @@ -1,11 +1,10 @@ ---- +--- ms.date: 06/09/2017 schema: 2.0.0 locale: en-us keywords: powershell,cmdlet title: about_Comparison_Operators --- - # About Comparison Operators ## SHORT DESCRIPTION @@ -94,13 +93,13 @@ False C:PS> 1,2,3 -eq 2 2 -PS C:\> "abc" -eq "abc" +PS> "abc" -eq "abc" True -PS C:\> "abc" -eq "abc", "def" +PS> "abc" -eq "abc", "def" False -PS C:\> "abc", "def" -eq "abc" +PS> "abc", "def" -eq "abc" abc ``` @@ -109,17 +108,18 @@ abc Description: Not equal to. Includes a different value. Example: + ```powershell -PS C:\> "abc" -ne "def" +PS> "abc" -ne "def" True -PS C:\> "abc" -ne "abc" +PS> "abc" -ne "abc" False -PS C:\> "abc" -ne "abc", "def" +PS> "abc" -ne "abc", "def" True -PS C:\> "abc", "def" -ne "abc" +PS> "abc", "def" -ne "abc" def ``` @@ -130,10 +130,10 @@ Description: Greater-than. Example: ```powershell -PS C:\> 8 -gt 6 +PS> 8 -gt 6 True -PS C:\> 7, 8, 9 -gt 8 +PS> 7, 8, 9 -gt 8 9 ``` @@ -144,10 +144,10 @@ Description: Greater-than or equal to. Example: ```powershell -PS C:\> 8 -ge 8 +PS> 8 -ge 8 True -PS C:\> 7, 8, 9 -ge 8 +PS> 7, 8, 9 -ge 8 8 9 ``` @@ -160,10 +160,10 @@ Example: ```powershell -PS C:\> 8 -lt 6 +PS> 8 -lt 6 False -PS C:\> 7, 8, 9 -lt 8 +PS> 7, 8, 9 -lt 8 7 ``` @@ -174,10 +174,10 @@ Description: Less-than or equal to. Example: ```powershell -PS C:\> 6 -le 8 +PS> 6 -le 8 True -PS C:\> 7, 8, 9 -le 8 +PS> 7, 8, 9 -le 8 7 8 ``` @@ -217,10 +217,10 @@ Description: Match using the wildcard character (\*). Example: ```powershell -PS C:\> "PowerShell" -like "*shell" +PS> "PowerShell" -like "*shell" True -PS C:\> "PowerShell", "Server" -like "*shell" +PS> "PowerShell", "Server" -like "*shell" PowerShell ``` @@ -231,10 +231,10 @@ Description: Does not match using the wildcard character (\*). Example: ```powershell -PS C:\> "PowerShell" -notlike "*shell" +PS> "PowerShell" -notlike "*shell" False -PS C:\> "PowerShell", "Server" -notlike "*shell" +PS> "PowerShell", "Server" -notlike "*shell" Server ``` @@ -255,11 +255,11 @@ For example, the following command submits a collection of strings to the that match. It does not populate the `$Matches` automatic variable. ```powershell -PS C:\> "Sunday", "Monday", "Tuesday" -match "sun" +PS> "Sunday", "Monday", "Tuesday" -match "sun" Sunday -PS C:\> $matches -PS C:\> +PS> $matches +PS> ``` In contrast, the following command submits a single string to the `-match` @@ -267,10 +267,10 @@ operator. The `-match` operator returns a Boolean value and populates the `$Matches` automatic variable. ```powershell -PS C:\> "Sunday" -match "sun" +PS> "Sunday" -match "sun" True -PS C:\> $matches +PS> $matches Name Value ---- ----- @@ -281,16 +281,16 @@ The `-notmatch` operator populates the `$Matches` automatic variable when the input is scalar and the result is False, that it, when it detects a match. ```powershell -PS C:\> "Sunday" -notmatch "rain" +PS> "Sunday" -notmatch "rain" True -PS C:\> $matches -PS C:\> +PS> $matches +PS> -PS C:\> "Sunday" -notmatch "day" +PS> "Sunday" -notmatch "day" False -PS C:\> $matches +PS> $matches Name Value ---- ----- @@ -305,15 +305,15 @@ is scalar, it populates the `$Matches` automatic variable. Example: ```powershell -PS C:\> "Sunday" -notmatch "sun" +PS> "Sunday" -notmatch "sun" False -PS C:\> $matches +PS> $matches Name Value ---- ----- 0 sun -PS C:\> "Sunday", "Monday" -notmatch "sun" +PS> "Sunday", "Monday" -notmatch "sun" Monday ``` @@ -348,23 +348,23 @@ Syntax: Examples: ```powershell -PS C:\> "abc", "def" -contains "def" +PS> "abc", "def" -contains "def" True -PS C:\> "Windows", "PowerShell" -contains "Shell" +PS> "Windows", "PowerShell" -contains "Shell" False #Not an exact match # Does the list of computers in $DomainServers include $ThisComputer? -PS C:\> $DomainServers -contains $thisComputer +PS> $DomainServers -contains $thisComputer True -PS C:\> "abc", "def", "ghi" -contains "abc", "def" +PS> "abc", "def", "ghi" -contains "abc", "def" False -PS C:\> $a = "abc", "def" -PS C:\> "abc", "def", "ghi" -contains $a +PS> $a = "abc", "def" +PS> "abc", "def", "ghi" -contains $a False -PS C:\> $a, "ghi" -contains $a +PS> $a, "ghi" -contains $a True ``` @@ -385,7 +385,7 @@ Syntax: Examples: ```powershell -PS C:\> "Windows", "PowerShell" -notcontains "Shell" +PS> "Windows", "PowerShell" -notcontains "Shell" True #Not an exact match # Get cmdlet parameters, but exclude common parameters @@ -402,9 +402,9 @@ function get-parms ($cmdlet) } # Find unapproved verbs in the functions in my module -PS C:\> $ApprovedVerbs = Get-Verb | foreach {$_.verb} -PS C:\> $myVerbs = Get-Command -Module MyModule | foreach {$_.verb} -PS C:\> $myVerbs | where {$ApprovedVerbs -notcontains $_} +PS> $ApprovedVerbs = Get-Verb | foreach {$_.verb} +PS> $myVerbs = Get-Command -Module MyModule | foreach {$_.verb} +PS> $myVerbs | where {$ApprovedVerbs -notcontains $_} ForEach Sort Tee @@ -430,24 +430,24 @@ Syntax: Examples: ```powershell -PS C:\> "def" -in "abc", "def" +PS> "def" -in "abc", "def" True -PS C:\> "Shell" -in "Windows", "PowerShell" +PS> "Shell" -in "Windows", "PowerShell" False #Not an exact match -PS C:\> "Windows" -in "Windows", "PowerShell" +PS> "Windows" -in "Windows", "PowerShell" True #An exact match -PS C:\> "Windows", "PowerShell" -in "Windows", "PowerShell", "ServerManager" +PS> "Windows", "PowerShell" -in "Windows", "PowerShell", "ServerManager" False #Using reference equality -PS C:\> $a = "Windows", "PowerShell" -PS C:\> $a -in $a, "ServerManager" +PS> $a = "Windows", "PowerShell" +PS> $a -in $a, "ServerManager" True #Using reference equality -# Does the list of computers in $domainServers include $thisComputer? -PS C:\> $thisComputer -in $domainServers +# Does the list of computers in $DomainServers include $ThisComputer? +PS> $thisComputer -in $domainServers True ``` @@ -470,23 +470,23 @@ Syntax: Examples: ```powershell -PS C:\> "def" -notin "abc", "def" +PS> "def" -notin "abc", "def" False -PS C:\> "ghi" -notin "abc", "def" +PS> "ghi" -notin "abc", "def" True -PS C:\> "Shell" -notin "Windows", "PowerShell" +PS> "Shell" -notin "Windows", "PowerShell" True #Not an exact match -PS C:\> "Windows" -notin "Windows", "PowerShell" +PS> "Windows" -notin "Windows", "PowerShell" False #An exact match # Find unapproved verbs in the functions in my module -PS C:\> $ApprovedVerbs = Get-Verb | foreach {$_.verb} -PS C:\> $MyVerbs = Get-Command -Module MyModule | foreach {$_.verb} +PS> $ApprovedVerbs = Get-Verb | foreach {$_.verb} +PS> $MyVerbs = Get-Command -Module MyModule | foreach {$_.verb} -PS C:\> $MyVerbs | where {$_ -notin $ApprovedVerbs} +PS> $MyVerbs | where {$_ -notin $ApprovedVerbs} ForEach Sort Tee @@ -515,17 +515,17 @@ sensitive, use `-creplace`. To make it explicitly case-insensitive, use `-ireplace`. Consider the following examples: ```powershell -PS C:\> "book" -replace "B", "C" +PS> "book" -replace "B", "C" Cook ``` ```powershell -PS C:\> "book" -ireplace "B", "C" +PS> "book" -ireplace "B", "C" Cook ``` ```powershell -PS C:\> "book" -creplace "B", "C" +PS> "book" -creplace "B", "C" book ``` @@ -543,11 +543,11 @@ Syntax: Example: ```powershell -PS C:\> $a = 1 -PS C:\> $b = "1" -PS C:\> $a -is [int] +PS> $a = 1 +PS> $b = "1" +PS> $a -is [int] True -PS C:\> $a -is $b.GetType() +PS> $a -is $b.GetType() False ``` @@ -560,11 +560,11 @@ Syntax: Example: ```powershell -PS C:\> $a = 1 -PS C:\> $b = "1" -PS C:\> $a -isnot $b.GetType() +PS> $a = 1 +PS> $b = "1" +PS> $a -isnot $b.GetType() True -PS C:\> $b -isnot [int] +PS> $b -isnot [int] True ``` diff --git a/reference/3.0/Microsoft.PowerShell.Core/About/about_Continue.md b/reference/3.0/Microsoft.PowerShell.Core/About/about_Continue.md index 1db1ad2a2583..5f55a5db4023 100644 --- a/reference/3.0/Microsoft.PowerShell.Core/About/about_Continue.md +++ b/reference/3.0/Microsoft.PowerShell.Core/About/about_Continue.md @@ -1,10 +1,9 @@ ---- +--- ms.date: 06/25/2017 schema: 2.0.0 keywords: powershell,cmdlet title: about_Continue --- - # About Continue ## SHORT DESCRIPTION diff --git a/reference/3.0/Microsoft.PowerShell.Core/About/about_Core_Commands.md b/reference/3.0/Microsoft.PowerShell.Core/About/about_Core_Commands.md index ae597f47e377..4ffcfb822f6e 100644 --- a/reference/3.0/Microsoft.PowerShell.Core/About/about_Core_Commands.md +++ b/reference/3.0/Microsoft.PowerShell.Core/About/about_Core_Commands.md @@ -1,11 +1,10 @@ ---- +--- ms.date: 06/09/2017 schema: 2.0.0 locale: en-us keywords: powershell,cmdlet title: about_Core_Commands --- - # About Core Commands ## SHORT DESCRIPTION diff --git a/reference/3.0/Microsoft.PowerShell.Core/About/about_Data_Sections.md b/reference/3.0/Microsoft.PowerShell.Core/About/about_Data_Sections.md index 8e39b2c1a71b..352a70844795 100644 --- a/reference/3.0/Microsoft.PowerShell.Core/About/about_Data_Sections.md +++ b/reference/3.0/Microsoft.PowerShell.Core/About/about_Data_Sections.md @@ -1,12 +1,12 @@ ---- +--- ms.date: 06/09/2017 schema: 2.0.0 locale: en-us keywords: powershell,cmdlet title: about_Data_Sections --- - # About Data Sections + ## about_Data_Sections @@ -39,6 +39,7 @@ sections will not run in Windows PowerShell 1.0 without revision. ### Syntax The syntax for a Data section is as follows: + ```powershell DATA [-supportedCommand ] { @@ -83,6 +84,8 @@ a ```powershell @( "red", "green", "blue" ) ``` + + ```powershell @{ a = 0x1; b = "great"; c ="script" } ``` @@ -179,7 +182,7 @@ A single-quoted here-string that uses the ConvertFrom-StringData cmdlet: ```powershell DATA { - ConvertFrom-StringData -stringdata @' + ConvertFrom-StringData -StringData @' Text001 = Windows 7 Text002 = Windows Server 2008 R2 '@ @@ -190,7 +193,7 @@ A double-quoted here-string that uses the ConvertFrom-StringData cmdlet: ```powershell DATA { - ConvertFrom-StringData -stringdata @" + ConvertFrom-StringData -StringData @" Msg1 = To start, press any key. Msg2 = To exit, type "quit". "@ diff --git a/reference/3.0/Microsoft.PowerShell.Core/About/about_Debuggers.md b/reference/3.0/Microsoft.PowerShell.Core/About/about_Debuggers.md index e9801c1ed08d..a0648b04cb62 100644 --- a/reference/3.0/Microsoft.PowerShell.Core/About/about_Debuggers.md +++ b/reference/3.0/Microsoft.PowerShell.Core/About/about_Debuggers.md @@ -1,11 +1,10 @@ ---- +--- ms.date: 11/27/2017 schema: 2.0.0 locale: en-us keywords: powershell,cmdlet title: about_Debuggers --- - # About Debuggers ## SHORT DESCRIPTION @@ -223,7 +222,7 @@ For example, the following command gets the variables in the local (script) scope: ```powershell -get-variable -scope 0 +Get-Variable -Scope 0 ``` You can abbreviate the command as: @@ -273,13 +272,13 @@ debugger steps into the workflow function, the debugger prompt changes to [WFDBG]. ```powershell -PS C:> Set-PSBreakpoint -Script C:\TestWFDemo1.ps1 -Line 8 +PS> Set-PSBreakpoint -Script C:\TestWFDemo1.ps1 -Line 8 ID Script Line Command Variable Action -- ------ ---- ------- -------- ------ 0 TestWFDemo1.ps1 8 -PS C:> C:\TestWFDemo1.ps1 +PS> C:\TestWFDemo1.ps1 Entering debug mode. Use h or ? for help. Hit Line breakpoint on 'C:\TestWFDemo1.ps1:8' @@ -288,69 +287,60 @@ At C:\TestWFDemo1.ps1:8 char:5 + Write-Output -InputObject "Now writing output:" # +!INCLUDE[]~~~~~ -[WFDBG:localhost]: PS C:>> list +[WFDBG:localhost]: PS>> list # 3: 4: workflow SampleWorkflowTest 5: { -6: param ($MyOutput) -# 7: +6: param ($MyOutput)# 7: 8:* Write-Output -InputObject "Now writing output:" -9: Write-Output -Input $MyOutput -# 10: +9: Write-Output -Input $MyOutput# 10: 11: Write-Output -InputObject "Get PowerShell process:" -12: Get-Process -Name powershell -# 13: +12: Get-Process -Name powershell# 13: 14: Write-Output -InputObject "Workflow function complete." -15: } -# 16: +15: }# 16: 17: # Call workflow function 18: SampleWorkflowTest -MyOutput "Hello" -[WFDBG:localhost]: PS C:>> $MyOutput +[WFDBG:localhost]: PS>> $MyOutput Hello -[WFDBG:localhost]: PS C:>> stepOver +[WFDBG:localhost]: PS>> stepOver Now writing output: At C:\TestWFDemo1.ps1:9 char:5 + Write-Output -Input $MyOutput # +!INCLUDE[]~ -[WFDBG:localhost]: PS C:>> list +[WFDBG:localhost]: PS>> list 4: workflow SampleWorkflowTest 5: { -6: param ($MyOutput) -# 7: +6: param ($MyOutput)# 7: 8: Write-Output -InputObject "Now writing output:" -9:* Write-Output -Input $MyOutput -# 10: +9:* Write-Output -Input $MyOutput# 10: 11: Write-Output -InputObject "Get PowerShell process:" -12: Get-Process -Name powershell -# 13: +12: Get-Process -Name powershell# 13: 14: Write-Output -InputObject "Workflow function complete." -15: } -# 16: +15: }# 16: 17: # Call workflow function -18: SampleWorkflowTest -MyOutput "Hello" -# 19: +18: SampleWorkflowTest -MyOutput "Hello"# 19: -[WFDBG:localhost]: PS C:>> stepOver +[WFDBG:localhost]: PS>> stepOver Hello At C:\TestWFDemo1.ps1:11 char:5 + Write-Output -InputObject "Get PowerShell process:" # +!INCLUDE[]~~~~~~~~~ -[WFDBG:localhost]: PS C:>> stepOut +[WFDBG:localhost]: PS>> stepOut Get PowerShell process: Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName @@ -371,19 +361,19 @@ For example: ```powershell function test-cmdlet { begin { - write-output "Begin" + Write-Output "Begin" } process { - write-output "Process" + Write-Output "Process" } end { - write-output "End" + Write-Output "End" } } -C:\PS> set-psbreakpoint -command test-cmdlet +PS> set-psbreakpoint -command test-cmdlet -C:\PS> test-cmdlet +PS> test-cmdlet Begin Entering debug mode. Use h or ? for help. @@ -392,7 +382,7 @@ Hit Command breakpoint on 'prompt:test-cmdlet' test-cmdlet -[DBG]: C:\PS> c +[DBG]: PS> c Process Entering debug mode. Use h or ? for help. @@ -400,7 +390,7 @@ Hit Command breakpoint on 'prompt:test-cmdlet' test-cmdlet -[DBG]: C:\PS> c +[DBG]: PS> c End Entering debug mode. Use h or ? for help. @@ -408,7 +398,7 @@ Hit Command breakpoint on 'prompt:test-cmdlet' test-cmdlet -# [DBG]: C:\PS> +# [DBG]: PS> ``` ## Debugging Remote Scripts @@ -427,7 +417,7 @@ on which the session is running, and the DBG prompt that lets you know you are in debugging mode. ```powershell -Enter-Pssession -Cn localhost +Enter-PSSession -ComputerName localhost [localhost]: PS C:\psscripts> Set-PSBreakpoint .\ttest19.ps1 6,11,22,25 ID Script Line Command Variable Action @@ -441,27 +431,24 @@ ID Script Line Command Variable Action Hit Line breakpoint on 'C:\psscripts\ttest19.ps1:11' At C:\psscripts\ttest19.ps1:11 char:1 -+ $winRMName = "WinRM" -# + ~ ++ $winRMName = "WinRM"# + ~ [localhost]: [DBG]: PS C:\psscripts>> list -6: 1..5 | foreach { sleep 1; Write-Output "hello2day $_" } +6: 1..5 | ForEach-Object { Start-Sleep 1; Write-Output "hello2day $_" } 7: } # 8: 9: $count = 10 10: $psName = "PowerShell" 11:* $winRMName = "WinRM" -12: $myVar = 102 -# 13: +12: $myVar = 102# 13: 14: for ($i=0; $i -lt $count; $i++) 15: { -16: sleep 1 +16: Start-Sleep 1 17: Write-Output "Loop iteration is: $i" -18: Write-Output "MyVar is $myVar" -# 19: +18: Write-Output "MyVar is $myVar"# 19: 20: hello2day # 21: @@ -469,8 +456,7 @@ At C:\psscripts\ttest19.ps1:11 char:1 [localhost]: [DBG]: PS C:\psscripts>> stepover At C:\psscripts\ttest19.ps1:12 char:1 -+ $myVar = 102 -# + ~ ++ $myVar = 102# + ~ [localhost]: [DBG]: PS C:\psscripts>> quit [localhost]: PS C:\psscripts> Exit-PSSession @@ -552,8 +538,7 @@ Entering debug mode. Use h or ? for help. Hit Line breakpoint on 'C:\ps-test\test.ps1:1' -test.ps1:1 function psversion { -# DBG> +test.ps1:1 function psversion {# DBG> ``` Use the Step command (s) to execute the first statement in the script and to @@ -571,8 +556,7 @@ verify the value of the variable by displaying its value. In this case, the value is \$null. ```powershell -DBG> $scriptname -# DBG> +DBG> $scriptname# DBG> ``` Use another Step command (s) to execute the current statement and to @@ -610,7 +594,7 @@ steps to the next statement in the script. ```powershell DBG> o Windows PowerShell 2.0 -Have you run a background job today (start-job)? +Have you run a background job today (Start-Job)? test.ps1:13 "Done $scriptname" ``` @@ -669,15 +653,13 @@ PS C:\ps-test> .\test.ps1 Hit Variable breakpoint on 'C:\ps-test\test.ps1:$scriptname' (Write access) -test.ps1:11 $scriptname = $MyInvocation.mycommand.path -# DBG> +test.ps1:11 $scriptname = $MyInvocation.mycommand.path# DBG> ``` Display the current value of the \$scriptname variable, which is \$null. ```powershell -DBG> $scriptname -# DBG> +DBG> $scriptname# DBG> ``` Use a Step command (s) to execute the statement that populates the variable. @@ -703,7 +685,7 @@ displayed, but it is not executed. ```powershell DBG> v Windows PowerShell 2.0 -Have you run a background job today (start-job)? +Have you run a background job today (Start-Job)? test.ps1:13 "Done $scriptname" ``` @@ -742,8 +724,7 @@ Now, run the script. PS C:\ps-test> .\test.ps1 Hit Command breakpoint on 'C:\ps-test\test.ps1:psversion' -test.ps1:12 psversion -# DBG> +test.ps1:12 psversion# DBG> ``` The script reaches the breakpoint at the function call. At this point, the @@ -759,10 +740,10 @@ read-only, so you cannot add an action to the current breakpoint.) ```powershell DBG> c Windows PowerShell 2.0 -Have you run a background job today (start-job)? +Have you run a background job today (Start-Job)? Done C:\ps-test\test.ps1 -PS C:\ps-test> get-psbreakpoint | remove-psbreakpoint +PS C:\ps-test> get-psbreakpoint | Remove-PSBreakpoint PS C:\ps-test> ``` @@ -774,8 +755,8 @@ line-continuation character.) ```powershell PS C:\ps-test> set-psbreakpoint -command psversion -script test.ps1 ` --action { add-content "The value of `$scriptname is $scriptname." ` --path action.log} +-action { Add-Content "The value of `$scriptname is $scriptname." ` +-Path action.log} ``` You can also add actions that set conditions for the breakpoint. In the @@ -785,7 +766,7 @@ you to run scripts. (The backtick (`) is the continuation character.) ```powershell PS C:\ps-test> set-psbreakpoint -script test.ps1 -command psversion ` --action { if ((get-executionpolicy) -eq "RemoteSigned") { break }} +-action { if ((Get-ExecutionPolicy) -eq "RemoteSigned") { break }} ``` The Break keyword in the action directs the debugger to execute the diff --git a/reference/3.0/Microsoft.PowerShell.Core/About/about_Do.md b/reference/3.0/Microsoft.PowerShell.Core/About/about_Do.md index 93dd570312ef..858bfb241a7a 100644 --- a/reference/3.0/Microsoft.PowerShell.Core/About/about_Do.md +++ b/reference/3.0/Microsoft.PowerShell.Core/About/about_Do.md @@ -1,11 +1,10 @@ ---- +--- ms.date: 06/09/2017 schema: 2.0.0 locale: en-us keywords: powershell,cmdlet title: about_Do --- - # About Do ## SHORT DESCRIPTION @@ -56,9 +55,9 @@ The following example of a Do statement counts the items in an array until it reaches an item with a value of 0. ```powershell -C:\PS> $x = 1,2,78,0 -C:\PS> do { $count++; $a++; } while ($x[$a] -ne 0) -C:\PS> $count +PS> $x = 1,2,78,0 +PS> do { $count++; $a++; } while ($x[$a] -ne 0) +PS> $count 3 ``` @@ -66,9 +65,9 @@ The following example uses the Until keyword. Notice that the not equal to operator (`-ne`) is replaced by the equal to operator (`-eq`). ```powershell -C:\PS> $x = 1,2,78,0 -C:\PS> do { $count++; $a++; } until ($x[$a] -eq 0) -C:\PS> $count +PS> $x = 1,2,78,0 +PS> do { $count++; $a++; } until ($x[$a] -eq 0) +PS> $count 3 ``` diff --git a/reference/3.0/Microsoft.PowerShell.Core/About/about_Environment_Variables.md b/reference/3.0/Microsoft.PowerShell.Core/About/about_Environment_Variables.md index 4fa771a6171d..cedb91b2524d 100644 --- a/reference/3.0/Microsoft.PowerShell.Core/About/about_Environment_Variables.md +++ b/reference/3.0/Microsoft.PowerShell.Core/About/about_Environment_Variables.md @@ -1,11 +1,10 @@ ---- +--- ms.date: 06/09/2017 schema: 2.0.0 locale: en-us keywords: powershell,cmdlet title: about_Environment_Variables --- - # About Environment Variables ## SHORT DESCRIPTION @@ -92,7 +91,7 @@ by the name of the variable. For example, to display the value of the COMPUTERNAME environment variable, type: ```powershell -Get-Childitem Env:Computername +Get-ChildItem Env:Computername ``` To display the values of all the environment variables, type: @@ -220,7 +219,7 @@ more information about preference variables, see The environment variables that store preferences include: -* PSExecutionPolicyPreference +- PSExecutionPolicyPreference Stores the execution policy set for the current session. This environment variable exists only when you set an execution policy for a single session. @@ -235,7 +234,7 @@ The environment variables that store preferences include: For more information, see [about_Execution_Policies](about_Execution_Policies.md). -* PSModulePath +- PSModulePath Stores the paths to the default module directories. Windows PowerShell looks for modules in the specified directories when you do not specify a full path diff --git a/reference/3.0/Microsoft.PowerShell.Core/About/about_Eventlogs.md b/reference/3.0/Microsoft.PowerShell.Core/About/about_Eventlogs.md index 94f7d8ccec24..40917a15d595 100644 --- a/reference/3.0/Microsoft.PowerShell.Core/About/about_Eventlogs.md +++ b/reference/3.0/Microsoft.PowerShell.Core/About/about_Eventlogs.md @@ -1,11 +1,10 @@ ---- +--- ms.date: 11/27/2017 schema: 2.0.0 locale: en-us keywords: powershell,cmdlet title: about_Eventlogs --- - # About Eventlogs ## Short Description @@ -109,10 +108,10 @@ The following table lists the event log preference variables. By default, only the following event types are enabled: -* $LogEngineLifeCycleEvent -* $LogEngineHealthEvent -* $LogProviderLifeCycleEvent -* $LogProviderHealthEvent +- $LogEngineLifeCycleEvent +- $LogEngineHealthEvent +- $LogProviderLifeCycleEvent +- $LogProviderHealthEvent To enable an event type, set the preference variable for that event type to $true. For example, to enable command life-cycle events, type: diff --git a/reference/3.0/Microsoft.PowerShell.Core/About/about_Execution_Policies.md b/reference/3.0/Microsoft.PowerShell.Core/About/about_Execution_Policies.md index 3e185fb66558..99b79446a7f8 100644 --- a/reference/3.0/Microsoft.PowerShell.Core/About/about_Execution_Policies.md +++ b/reference/3.0/Microsoft.PowerShell.Core/About/about_Execution_Policies.md @@ -1,11 +1,10 @@ ---- +--- ms.date: 06/09/2017 schema: 2.0.0 locale: en-us keywords: powershell,cmdlet title: about_Execution_Policies --- - # About Execution Policies ## Short Description @@ -41,6 +40,7 @@ The Windows PowerShell execution policies are as follows: "Restricted" is the default policy. ### Restricted + - Default execution policy in Windows 8, Windows Server 2012, and Windows 8.1. @@ -53,6 +53,7 @@ script files (.psm1), and Windows PowerShell profiles (.ps1). ### AllSigned + - Scripts can run. - Requires that all scripts and configuration files @@ -66,6 +67,7 @@ untrusted. - Risks running signed, but malicious, scripts. ### RemoteSigned + - Scripts can run. This is the default execution policy in Windows Server 2012 R2. @@ -86,6 +88,7 @@ as by using the Unblock-File cmdlet. than the Internet and signed, but malicious, scripts. ### Unrestricted + - Unsigned scripts can run. (This risks running malicious scripts.) @@ -93,6 +96,7 @@ scripts.) files that are downloaded from the Internet. ### Bypass + - Nothing is blocked and there are no warnings or prompts. @@ -103,6 +107,7 @@ Windows PowerShell is the foundation for a program that has its own security model. ### Undefined + - There is no execution policy set in the current scope. - If the execution policy in all scopes is Undefined, the @@ -125,6 +130,7 @@ execution policy. The Scope values are listed in precedence order. ### Process + The execution policy affects only the current session (the current Windows PowerShell process). @@ -135,10 +141,12 @@ session is closed. You cannot change the policy by editing the variable value. ### CurrentUser + The execution policy affects only the current user. It is stored in the HKEY_CURRENT_USER registry subkey. ### LocalMachine + The execution policy affects all users on the current computer. It is stored in the HKEY_LOCAL_MACHINE registry subkey. @@ -221,6 +229,7 @@ Set-ExecutionPolicy -ExecutionPolicy ``` For example: + ```powershell Set-ExecutionPolicy -ExecutionPolicy RemoteSigned ``` @@ -232,6 +241,7 @@ Set-ExecutionPolicy -ExecutionPolicy -Scope ``` For example: + ```powershell Set-ExecutionPolicy RemoteSigned -Scope CurrentUser ``` @@ -254,6 +264,7 @@ the local computer, type: ```powershell Set-ExecutionPolicy Undefined ``` + Or, type: ```powershell @@ -275,6 +286,7 @@ the **ExecutionPolicy** parameter of powershell.exe to set the execution policy. For example: + ```powershell powershell.exe -ExecutionPolicy AllSigned ``` diff --git a/reference/3.0/Microsoft.PowerShell.Core/About/about_For.md b/reference/3.0/Microsoft.PowerShell.Core/About/about_For.md index 712698ba32eb..c1a6a940a662 100644 --- a/reference/3.0/Microsoft.PowerShell.Core/About/about_For.md +++ b/reference/3.0/Microsoft.PowerShell.Core/About/about_For.md @@ -1,18 +1,19 @@ ---- +--- ms.date: 06/09/2017 schema: 2.0.0 locale: en-us keywords: powershell,cmdlet title: about_For --- - # About For ## SHORT DESCRIPTION + Describes a language command you can use to run statements based on a conditional test. ## LONG DESCRIPTION + The For statement (also known as a For loop) is a language construct you can use to create a loop that runs commands in a command block while a specified condition evaluates to true. @@ -22,6 +23,7 @@ operate on a subset of these values. In most cases, if you want to iterate all the values in an array, consider using a Foreach statement. ### Syntax + The following shows the For statement syntax. ```powershell diff --git a/reference/3.0/Microsoft.PowerShell.Core/About/about_Foreach.md b/reference/3.0/Microsoft.PowerShell.Core/About/about_Foreach.md index 74a94ec39300..149961acc46b 100644 --- a/reference/3.0/Microsoft.PowerShell.Core/About/about_Foreach.md +++ b/reference/3.0/Microsoft.PowerShell.Core/About/about_Foreach.md @@ -1,11 +1,10 @@ ---- +--- ms.date: 11/28/2017 schema: 2.0.0 locale: en-us keywords: powershell,cmdlet title: about_Foreach --- - # About ForEach ## SHORT DESCRIPTION diff --git a/reference/3.0/Microsoft.PowerShell.Core/About/about_Format.ps1xml.md b/reference/3.0/Microsoft.PowerShell.Core/About/about_Format.ps1xml.md index f06a452fb02c..21e038584207 100644 --- a/reference/3.0/Microsoft.PowerShell.Core/About/about_Format.ps1xml.md +++ b/reference/3.0/Microsoft.PowerShell.Core/About/about_Format.ps1xml.md @@ -1,11 +1,10 @@ ---- +--- ms.date: 11/28/2017 schema: 2.0.0 locale: en-us keywords: powershell,cmdlet title: about_Format.ps1xml --- - # About Format.ps1xml ## Short Description @@ -279,7 +278,7 @@ To test the change, type `Get-Culture`, and then review the output, which includes the Calendar property. ```powershell -PS C:\> Get-Culture +PS> Get-Culture LCID Name Calendar DisplayName ---- ---- -------- ----------- @@ -292,11 +291,11 @@ The ViewDefinitions section of each Format.ps1xml file contains the `` tags that define each view. A typical `` tag includes the following tags: -* `` identifies the name of the view -* `` specifies the object type or types to which the view +- `` identifies the name of the view +- `` specifies the object type or types to which the view applies -* `` specifies how items in the view will be combined in groups -* ``, ``, ``, and `` +- `` specifies how items in the view will be combined in groups +- ``, ``, ``, and `` contain the tags that specify how each item will be displayed The `` tag can contain a `` tag for each object type @@ -367,9 +366,9 @@ The default displays of some basic object types are defined in the Types.ps1xml file in the `$PSHOME` directory. The nodes are named PsStandardMembers, and the subnodes use one of the following tags: -* `` -* `` -* `` +- `` +- `` +- `` For more information, see [about_Types.ps1xml](about_Types.ps1xml.md). @@ -379,9 +378,9 @@ To detect errors in the loading or application of Format.ps1xml files, use the `Trace-Command` cmdlet with any of the following format components as the value of the **Name** parameter: -* FormatFileLoading -* FormatViewBinding -* UpdateFormatData +- FormatFileLoading +- FormatViewBinding +- UpdateFormatData For more information, see [Trace-Command](../../Microsoft.PowerShell.Utility/Trace-Command.md) diff --git a/reference/3.0/Microsoft.PowerShell.Core/About/about_Functions.md b/reference/3.0/Microsoft.PowerShell.Core/About/about_Functions.md index a67e993a0423..bc67aea23c6a 100644 --- a/reference/3.0/Microsoft.PowerShell.Core/About/about_Functions.md +++ b/reference/3.0/Microsoft.PowerShell.Core/About/about_Functions.md @@ -1,11 +1,10 @@ ---- +--- ms.date: 11/28/2017 schema: 2.0.0 locale: en-us keywords: powershell,cmdlet title: about_Functions --- - # About Functions # SHORT DESCRIPTION @@ -99,7 +98,7 @@ function Get-NewPix { $start = Get-Date -Month 1 -Day 1 -Year 2010 $allpix = Get-ChildItem -Path $env:UserProfile\*.jpg -Recurse - $allpix | where {$_.LastWriteTime -gt $Start} + $allpix | Where-Object {$_.LastWriteTime -gt $Start} } ``` @@ -169,7 +168,7 @@ value of the $size parameter, and it excludes directories: ```powershell function Get-SmallFiles { Param($Size) - Get-ChildItem $HOME | where { + Get-ChildItem $HOME | Where-Object { $_.Length -lt $Size -and !$_.PSIsContainer } } @@ -198,7 +197,7 @@ Get-SmallFiles example: ```powershell function Get-SmallFiles ($Size = 100) { - Get-ChildItem $HOME | where { + Get-ChildItem $HOME | Where-Object { $_.Length -lt $Size -and !$_.PSIsContainer } } @@ -248,7 +247,7 @@ function Get-Extension { ``` ```powershell -C:\PS> Get-Extension myTextFile +PS> Get-Extension myTextFile myTextFile.txt ``` @@ -272,10 +271,10 @@ When you type the On switch parameter after the function name, the function displays "Switch on". Without the switch parameter, it displays "Switch off". ```powershell -C:\PS> Switch-Item -on +PS> Switch-Item -on Switch on -C:\PS> Switch-Item +PS> Switch-Item Switch off ``` @@ -283,10 +282,10 @@ You can also assign a Boolean value to a switch when you run the function, as shown in the following example: ```powershell -C:\PS> Switch-Item -on:$true +PS> Switch-Item -on:$true Switch on -C:\PS> Switch-Item -on:$false +PS> Switch-Item -on:$false Switch off ``` @@ -311,7 +310,7 @@ Get-MyCommand function. The parameters and parameter values are passed to the command using @Args. ```powershell -PS C:> Get-MyCommand -Name Get-ChildItem +PS> Get-MyCommand -Name Get-ChildItem CommandType Name ModuleName ----------- ---- ---------- Cmdlet Get-ChildItem Microsoft.PowerShell.Management @@ -360,7 +359,7 @@ To demonstrate this function, enter an list of numbers separated by commas, as shown in the following example: ```powershell -C:\PS> 1,2,4 | Get-Pipeline +PS> 1,2,4 | Get-Pipeline The value is: 1 The value is: 2 The value is: 4 @@ -387,7 +386,7 @@ If this function is run by using the pipeline, it displays the following results: ```powershell -C:\PS> 1,2,4 | Get-PipelineBeginEnd +PS> 1,2,4 | Get-PipelineBeginEnd Begin: The input is End: The input is 1 2 4 ``` @@ -412,7 +411,7 @@ at a time. The $input automatic variable is empty when the function reaches the End keyword. ```powershell -C:\PS> 1,2,4 | Get-PipelineInput +PS> 1,2,4 | Get-PipelineInput Processing: 1 Processing: 2 Processing: 4 @@ -436,7 +435,7 @@ either the whole entry or only the message portion of the entry: ```powershell filter Get-ErrorLog ([switch]$message) { - if ($message) { out-host -inputobject $_.Message } + if ($message) { Out-Host -InputObject $_.Message } else { $_ } } ``` @@ -454,7 +453,7 @@ the global scope in the following example: ```powershell function global:Get-DependentSvs { - Get-Service | where {$_.DependentServices} + Get-Service | Where-Object {$_.DependentServices} } ``` diff --git a/reference/3.0/Microsoft.PowerShell.Core/About/about_Functions_Advanced.md b/reference/3.0/Microsoft.PowerShell.Core/About/about_Functions_Advanced.md index 99d8549b8113..2cdebe5fad16 100644 --- a/reference/3.0/Microsoft.PowerShell.Core/About/about_Functions_Advanced.md +++ b/reference/3.0/Microsoft.PowerShell.Core/About/about_Functions_Advanced.md @@ -1,11 +1,10 @@ ---- +--- ms.date: 11/28/2017 schema: 2.0.0 locale: en-us keywords: powershell,cmdlet title: about_Functions_Advanced --- - # About Functions Advanced # SHORT DESCRIPTION @@ -51,7 +50,7 @@ function Send-Greeting Process { - write-host ("Hello " + $Name + "!") + Write-Host ("Hello " + $Name + "!") } } ``` diff --git a/reference/3.0/Microsoft.PowerShell.Core/About/about_Functions_Advanced_Methods.md b/reference/3.0/Microsoft.PowerShell.Core/About/about_Functions_Advanced_Methods.md index a3baad979492..4724a01ba389 100644 --- a/reference/3.0/Microsoft.PowerShell.Core/About/about_Functions_Advanced_Methods.md +++ b/reference/3.0/Microsoft.PowerShell.Core/About/about_Functions_Advanced_Methods.md @@ -1,11 +1,10 @@ ---- +--- ms.date: 01/03/2018 schema: 2.0.0 locale: en-us keywords: powershell,cmdlet title: about_Functions_Advanced_Methods --- - # About Functions Advanced Methods ## SHORT DESCRIPTION