diff --git a/reference/3.0/ISE/Get-IseSnippet.md b/reference/3.0/ISE/Get-IseSnippet.md index 7d74ac0fc548..76eca98bb38d 100644 --- a/reference/3.0/ISE/Get-IseSnippet.md +++ b/reference/3.0/ISE/Get-IseSnippet.md @@ -1,4 +1,4 @@ ---- +--- ms.date: 06/09/2017 schema: 2.0.0 locale: en-us @@ -7,10 +7,11 @@ online version: http://go.microsoft.com/fwlink/?LinkID=238787 external help file: ISE-help.xml title: Get-IseSnippet --- - # Get-IseSnippet + ## SYNOPSIS Gets snippets that the user created. + ## SYNTAX ``` @@ -18,6 +19,7 @@ Get-IseSnippet [] ``` ## DESCRIPTION + The **Get-ISESnippet** cmdlet gets the PS1XML files that contain reusable text "snippets" that the user created. It works only in Windows PowerShell ISE. @@ -27,26 +29,32 @@ When you use the New-IseSnippet cmdlet to create a snippet, New-IseSnippet creat **Get-IseSnippet** does not get built-in snippets or snippets that are imported from modules by using the Import-IseSnippet cmdlet. This cmdlet is introduced in Windows PowerShell 3.0. + ## EXAMPLES ### Example 1 + ``` -PS C:\> Get-ISESnippet +PS> Get-ISESnippet ``` This command gets all user-define snippets in the Snippets directory. + ### Example 2 + ``` -PS C:\> Invoke-Command -Computer (Get-Content Servers.txt) {Get-ISESnippet | Copy-Item -Destination \\Server01\Share01\Snippets} +PS> Invoke-Command -Computer (Get-Content Servers.txt) {Get-ISESnippet | Copy-Item -Destination \\Server01\Share01\Snippets} ``` This command copies all of the user-created snippets from a group of remote computers to a shared Snippets directory. The command uses the Invoke-Command cmdlet to run a **Get-ISESnippet** command on the computers in the Servers.txt file. A pipeline operator (|) sends the snippet files to the Copy-Item cmdlet, which copies them to the directory that is specified by the **Destination** parameter. + ### Example 3 + ``` -PS C:\> #Parse-Snippet Function +PS> #Parse-Snippet Function function Parse-Snippet { @@ -78,9 +86,11 @@ Text: (c) Fabrikam, Inc. 2012 ``` This function uses the **Get-ISESnippet** and Select-Xml cmdlets to display the Title and Text of each snippet on the local computer. + ### Example 4 + ``` -PS C:\> $psISE.CurrentPowerShellTab.Snippets | Format-Table DisplayTitle, Description +PS> $psISE.CurrentPowerShellTab.Snippets | Format-Table DisplayTitle, Description ``` This command displays the title and description of all snippets in the session, including built-in snippets, user-defined snippets, and imported snippets. @@ -93,22 +103,29 @@ The **Snippets** property represents snippets in the current session. The **$psISE.CurrentPowerShellTab.Snippets** command returns a **Microsoft.PowerShell.Host.ISE.ISESnippet** object that represents a snippet, unlike the **Get-IseSnippet** cmdlet, which returns a file object (System.Io.FileInfo) that represents a snippet file. The command also uses the Format-Table cmdlet to display the **DisplayTitle** and **Description** properties of the snippets in a table. + ## PARAMETERS ### CommonParameters + This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). + ## INPUTS ## OUTPUTS ### System.IO.FileInfo + **Get-ISESnippet** returns a file object that represents the snippet file. + ## NOTES -* The **New-IseSnippet** cmdlet stores new user-created snippets in unsigned .ps1xml files. As such, Windows PowerShell cannot add them to a session in which the execution policy is **AllSigned** or **Restricted**. In a **Restricted** or **AllSigned** session, you can create, get, and import unsigned user-created snippets, but you cannot use them in the session. + +- The **New-IseSnippet** cmdlet stores new user-created snippets in unsigned .ps1xml files. As such, Windows PowerShell cannot add them to a session in which the execution policy is **AllSigned** or **Restricted**. In a **Restricted** or **AllSigned** session, you can create, get, and import unsigned user-created snippets, but you cannot use them in the session. To use unsigned user-created snippets that the **Get-IseSnippet** cmdlet returns, change the execution policy, and then restart Windows PowerShell ISE. For more information about Windows PowerShell execution policies, see about_Execution_Policies. + ## RELATED LINKS [New-IseSnippet](New-IseSnippet.md) diff --git a/reference/3.0/ISE/ISE.md b/reference/3.0/ISE/ISE.md index 77a0ca1e18d7..44e0b12c8ec5 100644 --- a/reference/3.0/ISE/ISE.md +++ b/reference/3.0/ISE/ISE.md @@ -1,4 +1,4 @@ ---- +--- ms.date: 06/09/2017 schema: 2.0.0 locale: en-us @@ -9,19 +9,22 @@ Module Guid: bae93d8e-782c-4a23-b87f-8699bfc17ee0 title: ISE Module Name: ISE --- - # ISE Module + ## Description This section contains the help topics for the cmdlets that are installed with the Windows PowerShell ISE module. The ISE module contains cmdlets that add features to Windows PowerShell Integrated Scripting Environment (ISE). ## ISE Cmdlets -### [Get-IseSnippet](Get-IseSnippet.md) + +### Get-IseSnippet.md Gets snippets that the user created. -### [Import-IseSnippet](Import-IseSnippet.md) +### Import-IseSnippet.md + Imports ISE snippets into the current session -### [New-IseSnippet](New-IseSnippet.md) +### New-IseSnippet.md + Creates a Windows PowerShell ISE code snippet. \ No newline at end of file diff --git a/reference/3.0/ISE/Import-IseSnippet.md b/reference/3.0/ISE/Import-IseSnippet.md index b5e7381a4445..7a2e1434501b 100644 --- a/reference/3.0/ISE/Import-IseSnippet.md +++ b/reference/3.0/ISE/Import-IseSnippet.md @@ -1,4 +1,4 @@ ---- +--- ms.date: 06/09/2017 schema: 2.0.0 locale: en-us @@ -7,23 +7,27 @@ online version: http://go.microsoft.com/fwlink/?LinkID=242050 external help file: ISE-help.xml title: Import-IseSnippet --- - # Import-IseSnippet + ## SYNOPSIS Imports ISE snippets into the current session + ## SYNTAX ### FromFolder (Default) + ``` Import-IseSnippet [-Path] [-Recurse] [] ``` ### FromModule + ``` Import-IseSnippet [-Recurse] -Module [-ListAvailable] [] ``` ## DESCRIPTION + The **Import-IseSnippet** cmdlet imports reusable text "snippets" from a module or a directory into the current session. The snippets are immediately available for use in Windows PowerShell ISE. This cmdlet works only in Windows PowerShell® Integrated Scripting Environment (ISE). @@ -41,45 +45,57 @@ You can move or copy the snippets to the Snippets directory of a Windows PowerSh NOTE: The Get-IseSnippet cmdlet, which gets user-created snippets in the local snippets directory, does not get imported snippets. This cmdlet is introduced in Windows PowerShell 3.0. + ## EXAMPLES ### Example 1: Import snippets from a directory + ``` -PS C:\> Import-IseSnippet -Path \\Server01\Public\Snippets -Recurse +PS> Import-IseSnippet -Path \\Server01\Public\Snippets -Recurse ``` This command imports the snippets from the \\\\Server01\Public\Snippets directory into the current session. It uses the Recurse parameter to get snippets from all subdirectories of the Snippets directory. + ### Example 2: Import snippets from a module + ``` -PS C:\> Import-IseSnippet -Module SnippetModule -ListAvailable +PS> Import-IseSnippet -Module SnippetModule -ListAvailable ``` This command imports the snippets from the SnippetModule module. The command uses the **ListAvailable** parameter to import the snippets even if the SnippetModule module is not imported into the user's session when the command runs. + ### Example 3: Find snippets in modules + ``` -PS C:\> ($env:PSModulePath).split(";") | foreach {dir $_\*\Snippets\*.Snippets.ps1xml -ErrorAction SilentlyContinue} | foreach {$_.fullname} +PS> ($env:PSModulePath).split(";") | foreach {dir $_\*\Snippets\*.Snippets.ps1xml -ErrorAction SilentlyContinue} | foreach {$_.fullname} ``` This command gets snippets in all installed modules in the PSModulePath environment variable. + ### Example 4: Import all module snippets + ``` -PS C:\> ($env:PSModulePath).split(";") | foreach {dir $_\*\Snippets\*.Snippets.ps1xml -ErrorAction SilentlyContinue} | foreach {$psise.CurrentPowerShellTab.Snippets.Load($_)} +PS> ($env:PSModulePath).split(";") | foreach {dir $_\*\Snippets\*.Snippets.ps1xml -ErrorAction SilentlyContinue} | foreach {$psise.CurrentPowerShellTab.Snippets.Load($_)} ``` This command imports all snippets from all installed modules into the current session. Typically, you don't need to run a command like this because modules that have snippets will use the **Import-IseSnippet** cmdlet to import them for you when the module is imported. + ### Example 5: Copy all module snippets + ``` -PS C:\> ($env:PSModulePath).split(";") | foreach {dir $_\*\Snippets\*.Snippets.ps1xml -ErrorAction SilentlyContinue} | Copy-Item -Destination $home\Documents\WindowsPowerShell\Snippets +PS> ($env:PSModulePath).split(";") | foreach {dir $_\*\Snippets\*.Snippets.ps1xml -ErrorAction SilentlyContinue} | Copy-Item -Destination $home\Documents\WindowsPowerShell\Snippets ``` This command copies the snippet files from all installed modules into the Snippets directory of the current user. Unlike imported snippets, which affect only the current session, copied snippets are available in every Windows PowerShell ISE session. + ## PARAMETERS ### -ListAvailable + Gets snippets from modules that are installed on the computer, even if the modules are not imported into the current session. If this parameter is omitted, and the module that is specified by the **Module** parameter is not imported into the current session, the attempt to get the snippets from the module will fail. @@ -98,6 +114,7 @@ Accept wildcard characters: False ``` ### -Module + Imports snippets from the specified module into the current session. Wildcard characters are not supported. @@ -119,6 +136,7 @@ Accept wildcard characters: False ``` ### -Path + Imports snippets from the specified file system directory. Wildcards characters are supported. @@ -135,6 +153,7 @@ Accept wildcard characters: True ``` ### -Recurse + Imports snippets from all subdirectories of the value of the **Path** parameter. ```yaml @@ -150,25 +169,33 @@ Accept wildcard characters: False ``` ### CommonParameters + This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). + ## INPUTS ### None + This cmdlet does not take input from the pipeline. + ## OUTPUTS ### None + This cmdlet does not generate output. + ## NOTES -* You cannot use the Get-IseSnippet cmdlet to get imported snippets. **Get-IseSnippet** gets only snippets in the $home\Documents\WindowsPowerShell\Snippets directory. -* **Import-IseSnippet** uses the **Load** static method of Microsoft.PowerShell.Host.ISE.ISESnippetCollection objects. You can also use the Load method of snippets in the Windows PowerShell ISE object model: $psISE.CurrentPowerShellTab.Snippets.Load() -* The New-IseSnippet cmdlet stores new user-created snippets in unsigned .ps1xml files. As such, Windows PowerShell cannot load them into a session in which the execution policy is **AllSigned** or **Restricted**. In a **Restricted** or **AllSigned** session, you can create, get, and import unsigned user-created snippets, but you cannot use them in the session. + +- You cannot use the Get-IseSnippet cmdlet to get imported snippets. **Get-IseSnippet** gets only snippets in the $home\Documents\WindowsPowerShell\Snippets directory. +- **Import-IseSnippet** uses the **Load** static method of Microsoft.PowerShell.Host.ISE.ISESnippetCollection objects. You can also use the Load method of snippets in the Windows PowerShell ISE object model: $psISE.CurrentPowerShellTab.Snippets.Load() +- The New-IseSnippet cmdlet stores new user-created snippets in unsigned .ps1xml files. As such, Windows PowerShell cannot load them into a session in which the execution policy is **AllSigned** or **Restricted**. In a **Restricted** or **AllSigned** session, you can create, get, and import unsigned user-created snippets, but you cannot use them in the session. To use unsigned user-created snippets that the **Import-IseSnippet** cmdlet returns, change the execution policy, and then restart Windows PowerShell ISE. For more information about Windows PowerShell execution policies, see about_Execution_Policies. + ## RELATED LINKS [Get-IseSnippet](Get-IseSnippet.md) -[New-IseSnippet](New-IseSnippet.md) \ No newline at end of file +[New-IseSnippet](New-IseSnippet.md) diff --git a/reference/3.0/ISE/New-IseSnippet.md b/reference/3.0/ISE/New-IseSnippet.md index 07b7d82e5d24..93861e674895 100644 --- a/reference/3.0/ISE/New-IseSnippet.md +++ b/reference/3.0/ISE/New-IseSnippet.md @@ -1,4 +1,4 @@ ---- +--- ms.date: 06/09/2017 schema: 2.0.0 locale: en-us @@ -7,10 +7,11 @@ online version: http://go.microsoft.com/fwlink/?LinkID=225298 external help file: ISE-help.xml title: New-IseSnippet --- - # New-IseSnippet + ## SYNOPSIS Creates a Windows PowerShell ISE code snippet. + ## SYNTAX ``` @@ -19,6 +20,7 @@ New-IseSnippet [-Title] [-Description] [-Text] [-Auth ``` ## DESCRIPTION + The **New-ISESnippet** cmdlet creates a reusable text "snippet" for Windows PowerShell ISE. You can use snippets to add text to the Script pane or Command pane in Windows PowerShell ISE. This cmdlet is available only in Windows PowerShell ISE. @@ -35,11 +37,13 @@ Note: You cannot use user-created snippets in a session in which the execution p For more information, see the Notes section. This cmdlet is introduced in Windows PowerShell 3.0. + ## EXAMPLES ### Example 1 + ``` -PS C:\> New-IseSnippet -Title Comment-BasedHelp -Description "A template for comment-based help." -Text "<# +PS> New-IseSnippet -Title Comment-BasedHelp -Description "A template for comment-based help." -Text "<# .SYNOPSIS .DESCRIPTION .PARAMETER @@ -52,9 +56,11 @@ PS C:\> New-IseSnippet -Title Comment-BasedHelp -Description "A template for com This command creates a Comment-BasedHelp snippet for Windows PowerShell ISE. It creates a file named "Comment-BasedHelp.snippets.ps1xml" in the user's Snippets directory ($home\Documents\WindowsPowerShell\Snippets). + ### Example 2 + ``` -PS C:\> $m = @' +PS> $m = @' Param ( [parameter(Mandatory=$true)] @@ -63,24 +69,28 @@ Param ) '@ -PS C:\> New-ISESnippet -Text $m -Title Mandatory -Description "Adds a mandatory function parameter." -Author "Kim Akers, Fabrikam Corp." -Force +PS> New-ISESnippet -Text $m -Title Mandatory -Description "Adds a mandatory function parameter." -Author "Kim Akers, Fabrikam Corp." -Force ``` These commands create a Mandatory snippet for Windows PowerShell ISE. The first command saves the snippet text in the $m variable. The second command uses the **New-ISESnippet** cmdlet to create the snippet. The command uses the **Force** parameter to overwrite a previous snippet with the same name. + ### Example 3 + ``` -PS C:\> Copy-Item $home\Documents\WindowsPowerShell\Snippets\Mandatory.Snippets.ps1xml -Destination \\Server\Share +PS> Copy-Item $home\Documents\WindowsPowerShell\Snippets\Mandatory.Snippets.ps1xml -Destination \\Server\Share ``` This command uses the Copy-Item cmdlet to copy the Mandatory snippet from the folder where **New-ISESnippet** places it to the Server\Share file share. Because the Snippets.ps1xml files that **New-ISESnippet** creates are text (XML) files, you can use the Item cmdlets to get, changes, move, rename, and copy them. + ## PARAMETERS ### -Author + Identifies the author of the snippet. The author field appears in the snippet file, but it does not appear when you click the snippet name in Windows PowerShell ISE. @@ -97,6 +107,7 @@ Accept wildcard characters: False ``` ### -CaretOffset + Places the cursor on the specified character of the snippet text. Enter an integer that represents the cursor position, with "1" representing the first character of text. The default value, 0 (zero), places the cursor immediately before the first character of text. @@ -115,6 +126,7 @@ Accept wildcard characters: False ``` ### -Description + Provides a description of the snippet. The description value appears when you click the snippet name in Windows PowerShell ISE. This parameter is required. @@ -132,6 +144,7 @@ Accept wildcard characters: False ``` ### -Force + Overwrites snippet files with the same name in the same location. By default, **New-ISESnippet** does not overwrite files. @@ -148,6 +161,7 @@ Accept wildcard characters: False ``` ### -Text + Specifies the text value that is added when you select the snippet. The snippet text appears when you click the snippet name in Windows PowerShell ISE. This parameter is mandatory. @@ -165,6 +179,7 @@ Accept wildcard characters: False ``` ### -Title + Specifies a title or name for the snippet. The title also names the snippet file. This parameter is mandatory. @@ -182,24 +197,31 @@ Accept wildcard characters: False ``` ### CommonParameters + This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). + ## INPUTS ### None + This cmdlet does not take input from the pipeline. + ## OUTPUTS ### None + This cmdlet does not generate any output. + ## NOTES -* **New-IseSnippet** stores new user-created snippets in unsigned .ps1xml files. As such, Windows PowerShell cannot add them to a session in which the execution policy is **AllSigned** or **Restricted**. In a **Restricted** or **AllSigned** session, you can create, get, and import unsigned user-created snippets, but you cannot use them in the session. + +- **New-IseSnippet** stores new user-created snippets in unsigned .ps1xml files. As such, Windows PowerShell cannot add them to a session in which the execution policy is **AllSigned** or **Restricted**. In a **Restricted** or **AllSigned** session, you can create, get, and import unsigned user-created snippets, but you cannot use them in the session. If you use the **New-IseSnippet** cmdlet in a **Restricted** or **AllSigned** session, the snippet is created, but an error message appears when Windows PowerShell tries to add the newly created snippet to the session. To use the new snippet (and other unsigned user-created snippets), change the execution policy, and then restart Windows PowerShell ISE. For more information about Windows PowerShell execution policies, see about_Execution_Policies. -* - To change a snippet, edit the snippet file. You can edit snippet files in the Script pane of Windows PowerShell ISE. +- To change a snippet, edit the snippet file. You can edit snippet files in the Script pane of Windows PowerShell ISE. - To delete a snippet that you added, delete the snippet file. @@ -212,4 +234,4 @@ To use the new snippet (and other unsigned user-created snippets), change the ex [Get-IseSnippet](Get-IseSnippet.md) -[Import-IseSnippet](Import-IseSnippet.md) \ No newline at end of file +[Import-IseSnippet](Import-IseSnippet.md) 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 diff --git a/reference/README.md b/reference/README.md index f8292a7cef4e..abcd0e1b1edb 100644 --- a/reference/README.md +++ b/reference/README.md @@ -1,11 +1,10 @@ ---- +--- ms.date: 11/06/2017 schema: 2.0.0 locale: en-us keywords: powershell,cmdlet title: README --- - # PowerShell Reference Reference material is organized into release versions. The content for each