diff --git a/reference/docs-conceptual/developer/format/list-view-groupby.md b/reference/docs-conceptual/developer/format/list-view-groupby.md index d787e128fe71..edbbd81db555 100644 --- a/reference/docs-conceptual/developer/format/list-view-groupby.md +++ b/reference/docs-conceptual/developer/format/list-view-groupby.md @@ -7,7 +7,7 @@ title: List View (GroupBy) # List View (GroupBy) This example shows how to implement a list view that separates the rows of the list into groups. -This list view displays the properties of the [System.Serviceprocess.Servicecontroller?Displayproperty=Fullname](/dotnet/api/System.ServiceProcess.ServiceController) +This list view displays the properties of the [System.ServiceProcess.ServiceController](/dotnet/api/System.ServiceProcess.ServiceController) objects returned by the [Get-Service](/powershell/module/Microsoft.PowerShell.Management/Get-Service) cmdlet. For more information about the components of a list view, see [Creating a List View](./creating-a-list-view.md). @@ -19,11 +19,11 @@ cmdlet. For more information about the components of a list view, see [Creating formatting file. 1. Open Windows PowerShell, and run the following command to load the formatting file into the - current session: `Update-formatdata -prependpath PathToFormattingFile`. + current session: `Update-FormatData -PrependPath PathToFormattingFile`. > [!WARNING] > This formatting file defines the display of an object that is already defined by a Windows -> PowerShell formatting file. You must use the `prependPath` parameter when you run the cmdlet, and +> PowerShell formatting file. You must use the `PrependPath` parameter when you run the cmdlet, and > you cannot load this formatting file as a module. ## Demonstrates @@ -49,7 +49,7 @@ This formatting file demonstrates the following XML elements: ## Example -The following XML defines a list view that starts a new group whenever the value of the [System.Serviceprocess.Servicecontroller.Status](/dotnet/api/System.ServiceProcess.ServiceController.Status) +The following XML defines a list view that starts a new group whenever the value of the [System.ServiceProcess.ServiceController.Status](/dotnet/api/System.ServiceProcess.ServiceController.Status) property changes. When each group is started, a custom label is displayed that includes the new value of the property. @@ -87,7 +87,7 @@ value of the property. ``` -The following example shows how Windows PowerShell displays the [System.Serviceprocess.Servicecontroller?Displayproperty=Fullname](/dotnet/api/System.ServiceProcess.ServiceController) +The following example shows how Windows PowerShell displays the [System.ServiceProcess.ServiceController](/dotnet/api/System.ServiceProcess.ServiceController) objects after this format file is loaded. The blank lines added before and after the group label are automatically added by Windows PowerShell. diff --git a/reference/docs-conceptual/developer/format/list-view-labels.md b/reference/docs-conceptual/developer/format/list-view-labels.md index 3f2108f79421..e1cb164d3ec0 100644 --- a/reference/docs-conceptual/developer/format/list-view-labels.md +++ b/reference/docs-conceptual/developer/format/list-view-labels.md @@ -7,7 +7,7 @@ title: List View (Labels) # List View (Labels) This example shows how to implement a list view that displays a custom label for each row of the -list. This list view displays the properties of the [System.Serviceprocess.Servicecontroller?Displayproperty=Fullname](/dotnet/api/System.ServiceProcess.ServiceController) +list. This list view displays the properties of the [System.ServiceProcess.ServiceController](/dotnet/api/System.ServiceProcess.ServiceController) object that is returned by the [Get-Service](/powershell/module/Microsoft.PowerShell.Management/Get-Service) cmdlet. For more information about the components of a list view, see [Creating a List View](./creating-a-list-view.md). @@ -19,12 +19,12 @@ cmdlet. For more information about the components of a list view, see [Creating formatting file. 1. Open Windows PowerShell, and run the following command to load the formatting file into the - current session: `Update-formatdata -prependpath PathToFormattingFile`. + current session: `Update-FormatData -PrependPath PathToFormattingFile`. > [!WARNING] > This formatting file defines the display of an object that is already defined by a Windows -> PowerShell formatting file. You must use the `prependPath` parameter when you run the cmdlet, and +> PowerShell formatting file. You must use the `PrependPath` parameter when you run the cmdlet, and > you cannot load this formatting file as a module. ## Demonstrates @@ -92,7 +92,7 @@ the name of the property is displayed followed by the value of the property. ``` -The following example shows how Windows PowerShell displays the [System.Serviceprocess.Servicecontroller?Displayproperty=Fullname](/dotnet/api/System.ServiceProcess.ServiceController) +The following example shows how Windows PowerShell displays the [System.ServiceProcess.ServiceController](/dotnet/api/System.ServiceProcess.ServiceController) objects after this format file is loaded. ```powershell diff --git a/reference/docs-conceptual/developer/format/name-element-for-view-format.md b/reference/docs-conceptual/developer/format/name-element-for-view-format.md index 49d9775990de..ae3b6d3bb6bb 100644 --- a/reference/docs-conceptual/developer/format/name-element-for-view-format.md +++ b/reference/docs-conceptual/developer/format/name-element-for-view-format.md @@ -53,7 +53,7 @@ For more information about the different types of views, see the following topic ## Example -The following example shows a `View` element that defines a table view for the [System.Serviceprocess.Servicecontroller](/dotnet/api/System.ServiceProcess.ServiceController) +The following example shows a `View` element that defines a table view for the [System.ServiceProcess.ServiceController](/dotnet/api/System.ServiceProcess.ServiceController) object. The name of the view is "service". ```xml diff --git a/reference/docs-conceptual/developer/format/tablecontrol-element-format.md b/reference/docs-conceptual/developer/format/tablecontrol-element-format.md index bc0e4461de06..82a3e186bdaa 100644 --- a/reference/docs-conceptual/developer/format/tablecontrol-element-format.md +++ b/reference/docs-conceptual/developer/format/tablecontrol-element-format.md @@ -56,7 +56,7 @@ For more information about the components of a table view, see [Creating a Table ## Example -This example shows a `TableControl` element that is used to display the properties of the [System.Serviceprocess.Servicecontroller](/dotnet/api/System.ServiceProcess.ServiceController) +This example shows a `TableControl` element that is used to display the properties of the [System.ServiceProcess.ServiceController](/dotnet/api/System.ServiceProcess.ServiceController) object. ```xml diff --git a/reference/docs-conceptual/developer/format/typename-element-for-viewselectedby-format.md b/reference/docs-conceptual/developer/format/typename-element-for-viewselectedby-format.md index a5441ba1ee53..bfff80912059 100644 --- a/reference/docs-conceptual/developer/format/typename-element-for-viewselectedby-format.md +++ b/reference/docs-conceptual/developer/format/typename-element-for-viewselectedby-format.md @@ -53,7 +53,7 @@ and [Custom View Components](./creating-custom-controls.md). ## Example -The following example shows how to specify the [System.Serviceprocess.Servicecontroller](/dotnet/api/System.ServiceProcess.ServiceController) +The following example shows how to specify the [System.ServiceProcess.ServiceController](/dotnet/api/System.ServiceProcess.ServiceController) object for a list view. The same schema is used for table, wide, and custom views. ```xml diff --git a/reference/docs-conceptual/developer/format/view-element-format.md b/reference/docs-conceptual/developer/format/view-element-format.md index 2002f6d21c74..0aaccf24e87b 100644 --- a/reference/docs-conceptual/developer/format/view-element-format.md +++ b/reference/docs-conceptual/developer/format/view-element-format.md @@ -77,7 +77,7 @@ topics: ## Example -This example shows a `View` element that defines a table view for the [System.Serviceprocess.Servicecontroller](/dotnet/api/System.ServiceProcess.ServiceController) +This example shows a `View` element that defines a table view for the [System.ServiceProcess.ServiceController](/dotnet/api/System.ServiceProcess.ServiceController) object. ```xml diff --git a/reference/docs-conceptual/developer/format/viewselectedby-element-format.md b/reference/docs-conceptual/developer/format/viewselectedby-element-format.md index 56e20c1ea9db..b3c17e120d49 100644 --- a/reference/docs-conceptual/developer/format/viewselectedby-element-format.md +++ b/reference/docs-conceptual/developer/format/viewselectedby-element-format.md @@ -58,7 +58,7 @@ referenced, see [Defining Sets of Objects](./defining-selection-sets.md). ## Example -The following example shows how to specify the [System.Serviceprocess.Servicecontroller](/dotnet/api/System.ServiceProcess.ServiceController) +The following example shows how to specify the [System.ServiceProcess.ServiceController](/dotnet/api/System.ServiceProcess.ServiceController) object for a list view. The same schema is used for table, wide, and custom views. ```xml diff --git a/reference/docs-conceptual/developer/format/wide-view-basic.md b/reference/docs-conceptual/developer/format/wide-view-basic.md index e51562008867..8c655e1e54ac 100644 --- a/reference/docs-conceptual/developer/format/wide-view-basic.md +++ b/reference/docs-conceptual/developer/format/wide-view-basic.md @@ -6,7 +6,7 @@ title: Wide View (Basic) --- # Wide View (Basic) -This example shows how to implement a basic wide view that displays the [System.Serviceprocess.Servicecontroller?Displayproperty=Fullname](/dotnet/api/System.ServiceProcess.ServiceController) +This example shows how to implement a basic wide view that displays the [System.ServiceProcess.ServiceController](/dotnet/api/System.ServiceProcess.ServiceController) objects returned by the `Get-Service` cmdlet. For more information about the components of a wide view, see [Creating a Wide View](./creating-a-wide-view.md). @@ -37,7 +37,7 @@ This formatting file demonstrates the following XML elements: ## Example -The following XML defines a wide view that displays the value of the [System.Serviceprocess.Servicecontroller.Servicename](/dotnet/api/System.ServiceProcess.ServiceController.ServiceName) property. +The following XML defines a wide view that displays the value of the [System.ServiceProcess.ServiceController.ServiceName](/dotnet/api/System.ServiceProcess.ServiceController.ServiceName) property. ```xml @@ -63,7 +63,7 @@ The following XML defines a wide view that displays the value of the [System.Ser ``` -The following example shows how Windows PowerShell displays the [System.Serviceprocess.Servicecontroller?Displayproperty=Fullname](/dotnet/api/System.ServiceProcess.ServiceController) +The following example shows how Windows PowerShell displays the [System.ServiceProcess.ServiceController](/dotnet/api/System.ServiceProcess.ServiceController) objects after this format file is loaded. ```powershell diff --git a/reference/docs-conceptual/developer/format/wide-view-groupby.md b/reference/docs-conceptual/developer/format/wide-view-groupby.md index 5fac82caf7c7..547cf9f7b626 100644 --- a/reference/docs-conceptual/developer/format/wide-view-groupby.md +++ b/reference/docs-conceptual/developer/format/wide-view-groupby.md @@ -6,7 +6,7 @@ title: Wide View (GroupBy) --- # Wide View (GroupBy) -This example shows how to implement a wide view that displays groups of [System.Serviceprocess.Servicecontroller?Displayproperty=Fullname](/dotnet/api/System.ServiceProcess.ServiceController) +This example shows how to implement a wide view that displays groups of [System.ServiceProcess.ServiceController](/dotnet/api/System.ServiceProcess.ServiceController) objects returned by the `Get-Service` cmdlet. For more information about the components of a wide view, see [Creating a Wide View](./creating-a-wide-view.md). @@ -40,7 +40,7 @@ This formatting file demonstrates the following XML elements: ## Example The following XML defines a wide view that displays groups of objects. Each new group is started -when the value of the [System.Serviceprocess.Servicecontroller.Servicetype](/dotnet/api/System.ServiceProcess.ServiceController.ServiceType) +when the value of the [System.ServiceProcess.ServiceController.ServiceType](/dotnet/api/System.ServiceProcess.ServiceController.ServiceType) property changes. ```xml @@ -71,7 +71,7 @@ property changes. ``` -The following example shows how Windows PowerShell displays the [System.Serviceprocess.Servicecontroller?Displayproperty=Fullname](/dotnet/api/System.ServiceProcess.ServiceController) +The following example shows how Windows PowerShell displays the [System.ServiceProcess.ServiceController](/dotnet/api/System.ServiceProcess.ServiceController) objects after this format file is loaded. ```powershell diff --git a/reference/docs-conceptual/developer/help/autogenerated-elements-of-comment-based-help.md b/reference/docs-conceptual/developer/help/autogenerated-elements-of-comment-based-help.md index 9e1322afdbb0..31fdb4a6099f 100644 --- a/reference/docs-conceptual/developer/help/autogenerated-elements-of-comment-based-help.md +++ b/reference/docs-conceptual/developer/help/autogenerated-elements-of-comment-based-help.md @@ -23,20 +23,20 @@ its capitalization, change the function definition or the script filename. ### Syntax -The Syntax section of the Help topic is generated from the parameter list in the Param statement of -the function or script. To add detail to the Help topic syntax, such as the .NET type of a +The Syntax section of the Help topic is generated from the parameter list in the `param` statement +of the function or script. To add detail to the Help topic syntax, such as the .NET type of a parameter, add the detail to the parameter list. If you don't specify a parameter type, the **Object** type is inserted as the default value. ### Parameter List The Parameters section of the Help topic is generated from the parameter list in the function or -script and from the descriptions that you add using the `.Parameters` keyword or comments in the +script and from the descriptions that you add using the `.PARAMETER` keyword or comments in the parameter list. Parameters appear in the Parameters section in the same order that they appear in the parameter list. The spelling and capitalization of parameter names is also taken from the parameter list; it -isn't affected by the parameter name specified by the `.Parameter` keyword. +isn't affected by the parameter name specified by the `.PARAMETER` keyword. ### Common Parameters diff --git a/reference/docs-conceptual/developer/help/comment-based-help-keywords.md b/reference/docs-conceptual/developer/help/comment-based-help-keywords.md index e9dc368fa8cd..ff5970e18a42 100644 --- a/reference/docs-conceptual/developer/help/comment-based-help-keywords.md +++ b/reference/docs-conceptual/developer/help/comment-based-help-keywords.md @@ -33,14 +33,14 @@ The description of a parameter. You can include a `.PARAMETER` keyword for each function or script. The `.PARAMETER` keywords can appear in any order in the comment block, but the order in which the -parameters appear in the `Param` statement or function declaration determines the order in which the +parameters appear in the `param` statement or function declaration determines the order in which the parameters appear in Help topic. To change the order of parameters in the Help topic, change the -order of the parameters in the `Param` statement or function declaration. +order of the parameters in the `param` statement or function declaration. -You can also specify a parameter description by placing a comment in the `Param` statement -immediately before the parameter variable name. If you use both a `Param` statement comment and a +You can also specify a parameter description by placing a comment in the `param` statement +immediately before the parameter variable name. If you use both a `param` statement comment and a `.PARAMETER` keyword, the description associated with the `.PARAMETER` keyword is used, and the -`Param` statement comment is ignored. +`param` statement comment is ignored. ## `.EXAMPLE` diff --git a/reference/docs-conceptual/developer/help/examples-of-comment-based-help.md b/reference/docs-conceptual/developer/help/examples-of-comment-based-help.md index 53014c3db533..ba7274c8cb84 100644 --- a/reference/docs-conceptual/developer/help/examples-of-comment-based-help.md +++ b/reference/docs-conceptual/developer/help/examples-of-comment-based-help.md @@ -18,8 +18,8 @@ functions. function Add-Extension { param ([string]$Name,[string]$Extension = "txt") - $name = $name + "." + $extension - $name + $Name = $Name + "." + $Extension + $Name <# .SYNOPSIS @@ -42,11 +42,11 @@ function Add-Extension System.String. Add-Extension returns a string with the extension or file name. .EXAMPLE - PS> Add-Extension -name "File" + PS> Add-Extension -Name "File" File.txt .EXAMPLE - PS> Add-Extension -name "File" -extension "doc" + PS> Add-Extension -Name "File" -Extension "doc" File.doc .EXAMPLE @@ -66,7 +66,7 @@ The following output shows the results of a `Get-Help` command that displays the `Add-Extension` function. ```powershell -PS> Get-Help Add-Extension -full +PS> Get-Help Add-Extension -Full ``` ```Output @@ -105,7 +105,7 @@ PARAMETERS This cmdlet supports the common parameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, -WarningAction, -WarningVariable, -OutBuffer and -OutVariable. For more information, type - "get-help about_commonparameters". + "Get-Help about_CommonParameters". INPUTS None. You can't pipe objects to Add-Extension. @@ -115,12 +115,12 @@ OUTPUTS -------------------------- EXAMPLE 1 -------------------------- - PS> Add-Extension -name "File" + PS> Add-Extension -Name "File" File.txt -------------------------- EXAMPLE 2 -------------------------- - PS> Add-Extension -name "File" -extension "doc" + PS> Add-Extension -Name "File" -Extension "doc" File.doc -------------------------- EXAMPLE 3 -------------------------- @@ -137,8 +137,8 @@ RELATED LINKS The following sample function includes comment-based Help. -Notice the blank lines between the closing `#>` and the `Param` statement. In a script that doesn't -have a `Param` statement, there must be at least two blank lines between the final comment in the +Notice the blank lines between the closing `#>` and the `param` statement. In a script that doesn't +have a `param` statement, there must be at least two blank lines between the final comment in the Help topic and the first function declaration. Without these blank lines, `Get-Help` associates the Help topic with the function, instead of the script. @@ -169,23 +169,23 @@ Help topic with the function, instead of the script. PS> .\Update-Month.ps1 .EXAMPLE - PS> .\Update-Month.ps1 -inputpath C:\Data\January.csv + PS> .\Update-Month.ps1 -InputPath C:\Data\January.csv .EXAMPLE - PS> .\Update-Month.ps1 -inputpath C:\Data\January.csv -outputPath C:\Reports\2009\January.csv + PS> .\Update-Month.ps1 -InputPath C:\Data\January.csv -OutputPath C:\Reports\2009\January.csv #> -param ([string]$InputPath, [string]$OutPutPath) +param ([string]$InputPath, [string]$OutputPath) function Get-Data { } ``` The following command gets the script Help. Because the script isn't in a directory that's listed in -the Path environment variable, the `Get-Help` command that gets the script Help must specify the +the PATH environment variable, the `Get-Help` command that gets the script Help must specify the script path. ```powershell -PS> Get-Help c:\ps-test\update-month.ps1 -full +PS> Get-Help C:\ps-test\update-month.ps1 -Full ``` ```Output @@ -228,7 +228,7 @@ PARAMETERS This cmdlet supports the common parameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, -WarningAction, -WarningVariable, -OutBuffer and -OutVariable. For more information, type, - "get-help about_commonparameters". + "Get-Help about_CommonParameters". INPUTS None. You can't pipe objects to Update-Month.ps1. @@ -242,19 +242,19 @@ PS> .\Update-Month.ps1 -------------------------- EXAMPLE 2 -------------------------- -PS> .\Update-Month.ps1 -inputpath C:\Data\January.csv +PS> .\Update-Month.ps1 -InputPath C:\Data\January.csv -------------------------- EXAMPLE 3 -------------------------- -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 ``` -## Example 3: Parameter Descriptions in a Param Statement +## Example 3: Parameter Descriptions in a `param` Statement -This example shows how to insert parameter descriptions in the `Param` statement of a function or +This example shows how to insert parameter descriptions in the `param` statement of a function or script. This format is most useful when the parameter descriptions are brief. ```powershell @@ -264,14 +264,14 @@ function Add-Extension ( [string] # Specifies the file name. - $name, + $Name, [string] # Specifies the file name extension. "Txt" is the default. - $extension = "txt" + $Extension = "txt" ) - $name = $name + "." + $extension - $name + $Name = $Name + "." + $Extension + $Name <# .SYNOPSIS @@ -282,43 +282,43 @@ function Add-Extension ``` The results are the same as the results for Example 1. `Get-Help` interprets the parameter -descriptions as though they were accompanied by the `.Parameter` keyword. +descriptions as though they were accompanied by the `.PARAMETER` keyword. ## Example 4: Redirecting to an XML File You can write XML-based Help topics for functions and scripts. Although comment-based Help is easier to implement, XML-based Help is required if you want more precise control over Help content or if you are translating Help topics into multiple languages.The following example shows the first few -lines of the `Update-Month.ps1` script. The script uses the `.ExternalHelp` keyword to specify the +lines of the `Update-Month.ps1` script. The script uses the `.EXTERNALHELP` keyword to specify the path to an XML-based Help topic for the script. ```powershell -# .ExternalHelp C:\MyScripts\Update-Month-Help.xml +# .EXTERNALHELP C:\MyScripts\Update-Month-Help.xml - param ([string]$InputPath, [string]$OutPutPath) + param ([string]$InputPath, [string]$OutputPath) function Get-Data { } ``` -The following example shows the use of the `.ExternalHelp` keyword in a function. +The following example shows the use of the `.EXTERNALHELP` keyword in a function. ```powershell function Add-Extension { - param ([string] $name, [string]$extension = "txt") - $name = $name + "." + $extension - $name + param ([string]$Name, [string]$Extension = "txt") + $Name = $Name + "." + $Extension + $Name - # .ExternalHelp C:\ps-test\Add-Extension.xml + # .EXTERNALHELP C:\ps-test\Add-Extension.xml } ``` ## Example 5: Redirecting to a Different Help Topic -The following code is an excerpt from the beginning of the built-in `Help` function in PowerShell, +The following code is an excerpt from the beginning of the built-in `help` function in PowerShell, which displays one screen of Help text at a time. Because the Help topic for the Get-Help cmdlet -describes the Help function, the Help function uses the `.ForwardHelpTargetName` and -`.ForwardHelpCategory` keywords to redirect the user to the Get-Help cmdlet Help topic. +describes the Help function, the Help function uses the `.FORWARDHELPTARGETNAME` and +`.FORWARDHELPCATEGORY` keywords to redirect the user to the Get-Help cmdlet Help topic. ```powershell function help @@ -336,11 +336,11 @@ function help } ``` -The following command uses this feature. When a user types a `Get-Help` command for the `Help` +The following command uses this feature. When a user types a `Get-Help` command for the `help` function, `Get-Help` displays the Help topic for the `Get-Help` cmdlet. ```powershell -PS> get-help help +PS> Get-Help help ``` ```Output diff --git a/reference/docs-conceptual/developer/help/how-to-add-syntax-to-a-cmdlet-help-topic.md b/reference/docs-conceptual/developer/help/how-to-add-syntax-to-a-cmdlet-help-topic.md index 39c4a76b3e16..e0485f6bb73e 100644 --- a/reference/docs-conceptual/developer/help/how-to-add-syntax-to-a-cmdlet-help-topic.md +++ b/reference/docs-conceptual/developer/help/how-to-add-syntax-to-a-cmdlet-help-topic.md @@ -73,8 +73,8 @@ aren't required, because they're one of several values that might be used with t ``` SYNTAX - Get-Tech -name -type - Get-Tech -ID -list -type + Get-Tech -Name -Type + Get-Tech -Id -List -Type ``` Start each parameter set with the cmdlet name. @@ -82,7 +82,7 @@ aren't required, because they're one of several values that might be used with t List the default parameter set first. The default parameter is specified by the cmdlet class. For each parameter set, list its unique parameter first, unless there are positional parameters - that must appear first. In the previous example, the Name and ID parameters are unique parameters + that must appear first. In the previous example, the Name and Id parameters are unique parameters for the two parameter sets (each parameter set must have one parameter that's unique to that parameter set). This makes it easier for users to identify what parameter they need to supply for the parameter set. @@ -100,33 +100,33 @@ aren't required, because they're one of several values that might be used with t ``` SYNTAX - Get-Tech -name string -type basic advanced - Get-Tech -ID int -list -type basic advanced + Get-Tech -Name string -Type Basic Advanced + Get-Tech -Id int -List -Type Basic Advanced ``` Abbreviate types as long as their meaning is clear, such as **string** for **System.String** and **int** for **System.Int32**. - List all values of enumerations, such as the `-type` parameter in the previous example, which can + List all values of enumerations, such as the `-Type` parameter in the previous example, which can be set to **basic** or **advanced**. - Switch parameters, such as `-list` in the previous example, don't have values. + Switch parameters, such as `-List` in the previous example, don't have values. 1. Add angle brackets to parameters values that are placeholder, as compared to parameter values that are literals. ``` SYNTAX - Get-Tech -name -type basic advanced - Get-Tech -ID -list -type basic advanced + Get-Tech -Name -Type Basic Advanced + Get-Tech -Id -List -Type Basic Advanced ``` 1. Enclose optional parameters and their vales in square brackets. ``` SYNTAX - Get-Tech -name [-type basic advanced] - Get-Tech -ID [-list] [-type basic advanced] + Get-Tech -Name [-Type Basic Advanced] + Get-Tech -Id [-List] [-Type Basic Advanced] ``` 1. Enclose optional parameters names (for positional parameters) in square brackets. The name for @@ -135,8 +135,8 @@ aren't required, because they're one of several values that might be used with t ``` SYNTAX - Get-Tech [-name] [-type basic advanced] - Get-Tech -ID [-list] [-type basic advanced] + Get-Tech [-Name] [-Type Basic Advanced] + Get-Tech -Id [-List] [-Type Basic Advanced] ``` 1. If a parameter value can contain multiple values, such as a list of names in the Name parameter, @@ -144,8 +144,8 @@ aren't required, because they're one of several values that might be used with t ``` SYNTAX - Get-Tech [-name] [-type basic advanced] - Get-Tech -ID [-list] [-type basic advanced] + Get-Tech [-Name] [-Type Basic Advanced] + Get-Tech -Id [-List] [-Type Basic Advanced] ``` 1. If the user can choose from parameters or parameter values, such as the Type parameter, enclose @@ -153,8 +153,8 @@ aren't required, because they're one of several values that might be used with t ``` SYNTAX - Get-Tech [-name] [-type {basic | advanced}] - Get-Tech -ID [-list] [-type {basic | advanced}] + Get-Tech [-Name] [-Type {Basic | Advanced}] + Get-Tech -Id [-List] [-Type {Basic | Advanced}] ``` 1. If the parameter value must use specific formatting, such as quotation marks or parentheses, show @@ -162,8 +162,8 @@ aren't required, because they're one of several values that might be used with t ``` SYNTAX - Get-Tech [-name] <"string[]"> [-type {basic | advanced}] - Get-Tech -ID [-list] [-type {basic | advanced}] + Get-Tech [-Name] <"string[]"> [-Type {Basic | Advanced}] + Get-Tech -Id [-List] [-Type {Basic | Advanced}] ``` ## Coding the syntax diagram XML diff --git a/reference/docs-conceptual/developer/help/naming-help-files.md b/reference/docs-conceptual/developer/help/naming-help-files.md index 552ab9161f0d..c03c178fad2e 100644 --- a/reference/docs-conceptual/developer/help/naming-help-files.md +++ b/reference/docs-conceptual/developer/help/naming-help-files.md @@ -42,7 +42,7 @@ assembly. The `Get-Help` cmdlet looks for a help topic for the Certificate provi ## Function Help files Functions can be documented using [comment-based help][01] or documented in an XML help file. When -the function is documented in an XML file, the function must have an `.ExternalHelp` comment keyword +the function is documented in an XML file, the function must have an `.EXTERNALHELP` comment keyword that associates the function with the XML file. Otherwise, the `Get-Help` cmdlet can't find the help file. @@ -51,7 +51,7 @@ is to name the help file for the script module in which the function is defined. following function is defined in the `MyModule.psm1` file. ```csharp -#.ExternalHelp MyModule.psm1-help.xml +#.EXTERNALHELP MyModule.psm1-help.xml function Test-Function { ... } ``` @@ -63,7 +63,7 @@ defined. Use the following filename format: `.cdxml-help.xml` CIM commands are defined in CDXML files that can be included in modules as nested modules. When the -CIM command is imported into the session as a function, PowerShell adds an `.ExternalHelp` comment +CIM command is imported into the session as a function, PowerShell adds an `.EXTERNALHELP` comment keyword to the function definition that associates the function with an XML help file that is named for the CDXML file in which the CIM command is defined. @@ -75,12 +75,12 @@ help file for the script module in which the script workflow is defined. For exa `.psm1-help.xml` -Unlike other scripted commands, script workflows don't require an `.ExternalHelp` comment keyword to +Unlike other scripted commands, script workflows don't require an `.EXTERNALHELP` comment keyword to associate them with a help file. Instead, PowerShell searches the UI-Culture-specific subdirectories of the module directory for XML-based help files and looks for help for the script workflow in all -the files. `.ExternalHelp` comment keyword are ignored. +the files. `.EXTERNALHELP` comment keyword are ignored. -Because the `.ExternalHelp` comment keyword is ignored, the `Get-Help` cmdlet can find help for +Because the `.EXTERNALHELP` comment keyword is ignored, the `Get-Help` cmdlet can find help for script workflows only when they're included in modules. diff --git a/reference/docs-conceptual/developer/help/placing-comment-based-help-in-functions.md b/reference/docs-conceptual/developer/help/placing-comment-based-help-in-functions.md index 5b102551f292..c93479c9115e 100644 --- a/reference/docs-conceptual/developer/help/placing-comment-based-help-in-functions.md +++ b/reference/docs-conceptual/developer/help/placing-comment-based-help-in-functions.md @@ -32,7 +32,7 @@ The following example shows comment-based at the beginning of a function body. function MyProcess { <# - .Description + .DESCRIPTION The MyProcess function gets the Windows PowerShell process. #> @@ -50,7 +50,7 @@ function MyFunction Get-Process powershell <# - .Description + .DESCRIPTION The MyProcess function gets the Windows PowerShell process. #> } @@ -62,7 +62,7 @@ function MyFunction ```powershell <# - .Description + .DESCRIPTION The MyProcess function gets the Windows PowerShell process. #> function MyFunction { Get-Process powershell} diff --git a/reference/docs-conceptual/developer/help/placing-comment-based-help-in-scripts.md b/reference/docs-conceptual/developer/help/placing-comment-based-help-in-scripts.md index 111fa4fe5908..7f595adc9cb8 100644 --- a/reference/docs-conceptual/developer/help/placing-comment-based-help-in-scripts.md +++ b/reference/docs-conceptual/developer/help/placing-comment-based-help-in-scripts.md @@ -32,7 +32,7 @@ The following example shows comment-based at the beginning of a script. ```powershell <# -.Description +.DESCRIPTION This script performs a series of network connection tests. #> @@ -49,7 +49,7 @@ param [string]$ComputerName function Ping { Test-Connection -ComputerName $ComputerName } <# -.Description +.DESCRIPTION This script performs a series of network connection tests. #> ``` diff --git a/reference/docs-conceptual/developer/help/supporting-online-help.md b/reference/docs-conceptual/developer/help/supporting-online-help.md index 2ddc6601ab82..a0ae9c10e4d3 100644 --- a/reference/docs-conceptual/developer/help/supporting-online-help.md +++ b/reference/docs-conceptual/developer/help/supporting-online-help.md @@ -102,7 +102,7 @@ The following code shows the **HelpUri** attribute of the `New-Calendar` functio ```powershell function New-Calendar { [CmdletBinding(SupportsShouldProcess=$true, - HelpURI="https://go.microsoft.com/fwlink/?LinkID=01122")] + HelpUri="https://go.microsoft.com/fwlink/?LinkID=01122")] ``` ### Adding a HelpUri attribute to a cim command @@ -118,14 +118,14 @@ The following code shows the HelpUri attribute of the `Start-Debug` CIM command ### Adding a HelpUri attribute to a workflow -For workflows that are written in the PowerShell language, add an `.ExternalHelp` comment directive -to the workflow code. The value of the directive must be a URI that begins with `http` or `https`. +For workflows that are written in the PowerShell language, add an `.EXTERNALHELP` comment keyword +to the workflow code. The value of the keyword must be a URI that begins with `http` or `https`. > [!NOTE] > The HelpUri property isn't supported for XAML-based workflows in PowerShell. -The following code shows the .ExternalHelp directive in a workflow file. +The following code shows the `.EXTERNALHELP` keyword in a workflow file. ```powershell -# .ExternalHelp "https://go.microsoft.com/fwlink/?LinkID=138338" +# .EXTERNALHELP "https://go.microsoft.com/fwlink/?LinkID=138338" ``` diff --git a/reference/docs-conceptual/developer/help/syntax-of-comment-based-help.md b/reference/docs-conceptual/developer/help/syntax-of-comment-based-help.md index ba69c1d21e6b..2c56d74b08f9 100644 --- a/reference/docs-conceptual/developer/help/syntax-of-comment-based-help.md +++ b/reference/docs-conceptual/developer/help/syntax-of-comment-based-help.md @@ -35,7 +35,7 @@ This section describes the syntax of comment-based help. Each section of comment-based Help is defined by a keyword and each keyword is preceded by a dot (`.`). The keywords can appear in any order. The keyword names aren't case-sensitive. - A comment block must contain at least one help keyword. Some of the keywords, such as **EXAMPLE**, + A comment block must contain at least one help keyword. Some of the keywords, such as `.EXAMPLE`, can appear many times in the same comment block. The Help content for each keyword begins on the line after the keyword and can span multiple lines. @@ -43,12 +43,12 @@ This section describes the syntax of comment-based help. follows a comment that isn't part of the Help topic, there must be at least one blank line between the last non-Help comment line and the beginning of the comment-based Help. - For example, the following comment-based help topic contains the .Description keyword and its + For example, the following comment-based help topic contains the `.DESCRIPTION` keyword and its value, which is a description of a function or script. ```powershell <# - .Description + .DESCRIPTION The Get-Function function displays the name and syntax of all functions in the session. #> ``` diff --git a/reference/docs-conceptual/developer/help/updatable-help-overview.md b/reference/docs-conceptual/developer/help/updatable-help-overview.md index 0018eeb6af07..fbb5a962141e 100644 --- a/reference/docs-conceptual/developer/help/updatable-help-overview.md +++ b/reference/docs-conceptual/developer/help/updatable-help-overview.md @@ -63,7 +63,7 @@ Updatable Help includes the following features. parameter of the `Get-Help` cmdlet now gets the URL of an online help topic from the value of the **HelpUri** property of any command, if it can't find the online help URL in a help file. You can populate the **HelpUri** property by adding a **HelpUri** attribute to the code of cmdlets, - functions, and CIM commands, or using the **.Link** comment-based help directive in workflows and + functions, and CIM commands, or using the `.LINK` comment-based help keyword in workflows and scripts. To make our help files updatable, the Windows PowerShell modules in Windows don't come with help diff --git a/reference/docs-conceptual/developer/help/writing-help-for-windows-powershell-cmdlets.md b/reference/docs-conceptual/developer/help/writing-help-for-windows-powershell-cmdlets.md index ba7677428cc1..8e18c22f2538 100644 --- a/reference/docs-conceptual/developer/help/writing-help-for-windows-powershell-cmdlets.md +++ b/reference/docs-conceptual/developer/help/writing-help-for-windows-powershell-cmdlets.md @@ -55,7 +55,7 @@ description. ### Use conventional syntax -Use the standard Backus-Naur format which is common for Windows and UNIX command-line Help. +Use the standard Backus-Naur format which is common for Windows and Unix command-line Help. ### Use Microsoft .NET types for parameter values diff --git a/reference/docs-conceptual/developer/help/writing-help-for-windows-powershell-scripts-and-functions.md b/reference/docs-conceptual/developer/help/writing-help-for-windows-powershell-scripts-and-functions.md index 2fb286b51174..fbd50ffb0ff2 100644 --- a/reference/docs-conceptual/developer/help/writing-help-for-windows-powershell-scripts-and-functions.md +++ b/reference/docs-conceptual/developer/help/writing-help-for-windows-powershell-scripts-and-functions.md @@ -29,11 +29,11 @@ information about writing comment-based help topics, see [about_Comment_Based_He ### XML-Based Command Help The help topic that describes a script or function can be implemented in an XML file that uses the -command help schema. To associate the script or function with the XML file, use the `ExternalHelp` +command help schema. To associate the script or function with the XML file, use the `.EXTERNALHELP` comment keyword followed by the path and name of the XML file. -When the `ExternalHelp` comment keyword is present, it takes precedence over comment-based help, -even when `Get-Help` can't find a help file that matches the value of the `ExternalHelp` keyword. +When the `.EXTERNALHELP` comment keyword is present, it takes precedence over comment-based help, +even when `Get-Help` can't find a help file that matches the value of the `.EXTERNALHELP` keyword. ### Online Help diff --git a/reference/docs-conceptual/developer/hosting/adding-and-invoking-commands.md b/reference/docs-conceptual/developer/hosting/adding-and-invoking-commands.md index 6f44282f51eb..b164db79fb5e 100644 --- a/reference/docs-conceptual/developer/hosting/adding-and-invoking-commands.md +++ b/reference/docs-conceptual/developer/hosting/adding-and-invoking-commands.md @@ -11,19 +11,19 @@ then invoke the pipeline synchronously or asynchronously. ## Creating a pipeline -The [System.Management.Automation.Powershell](/dotnet/api/system.management.automation.powershell) +The [System.Management.Automation.PowerShell](/dotnet/api/system.management.automation.powershell) class provides several methods to add commands, parameters, and scripts to the pipeline. You can invoke the pipeline synchronously by calling an overload of the -[System.Management.Automation.Powershell.Invoke*](/dotnet/api/System.Management.Automation.PowerShell.Invoke) +[System.Management.Automation.PowerShell.Invoke*](/dotnet/api/System.Management.Automation.PowerShell.Invoke) method, or asynchronously by calling an overload of the -[System.Management.Automation.Powershell.Begininvoke*](/dotnet/api/System.Management.Automation.PowerShell.BeginInvoke) +[System.Management.Automation.PowerShell.BeginInvoke*](/dotnet/api/System.Management.Automation.PowerShell.BeginInvoke) and then the -[System.Management.Automation.Powershell.Endinvoke*](/dotnet/api/System.Management.Automation.PowerShell.EndInvoke) +[System.Management.Automation.PowerShell.EndInvoke*](/dotnet/api/System.Management.Automation.PowerShell.EndInvoke) method. ### AddCommand -1. Create a [System.Management.Automation.Powershell](/dotnet/api/system.management.automation.powershell) object. +1. Create a [System.Management.Automation.PowerShell](/dotnet/api/system.management.automation.powershell) object. ```csharp PowerShell ps = PowerShell.Create(); @@ -42,30 +42,30 @@ method. ``` If you call the -[System.Management.Automation.Powershell.Addcommand*](/dotnet/api/System.Management.Automation.PowerShell.AddCommand) +[System.Management.Automation.PowerShell.AddCommand*](/dotnet/api/System.Management.Automation.PowerShell.AddCommand) method more than once before you call the -[System.Management.Automation.Powershell.Invoke*](/dotnet/api/System.Management.Automation.PowerShell.Invoke) +[System.Management.Automation.PowerShell.Invoke*](/dotnet/api/System.Management.Automation.PowerShell.Invoke) method, the result of the first command is piped to the second, and so on. If you do not want to pipe the result of a previous command to a command, add it by calling the -[System.Management.Automation.Powershell.Addstatement*](/dotnet/api/System.Management.Automation.PowerShell.AddStatement) +[System.Management.Automation.PowerShell.AddStatement*](/dotnet/api/System.Management.Automation.PowerShell.AddStatement) instead. ### AddParameter The previous example executes a single command without any parameters. You can add parameters to the command by using the - [System.Management.Automation.Pscommand.Addparameter*](/dotnet/api/System.Management.Automation.PSCommand.AddParameter) + [System.Management.Automation.PSCommand.AddParameter*](/dotnet/api/System.Management.Automation.PSCommand.AddParameter) method For example, the following code gets a list of all of the processes that are named - `PowerShell` running on the machine. + `powershell` running on the machine. ```csharp PowerShell.Create().AddCommand("Get-Process") - .AddParameter("Name", "PowerShell") + .AddParameter("Name", "powershell") .Invoke(); ``` You can add additional parameters by calling -[System.Management.Automation.Pscommand.Addparameter*](/dotnet/api/System.Management.Automation.PSCommand.AddParameter) +[System.Management.Automation.PSCommand.AddParameter*](/dotnet/api/System.Management.Automation.PSCommand.AddParameter) repeatedly. ```csharp @@ -76,7 +76,7 @@ PowerShell.Create().AddCommand("Get-Command") ``` You can also add a dictionary of parameter names and values by calling the -[System.Management.Automation.Powershell.Addparameters*](/dotnet/api/System.Management.Automation.PowerShell.AddParameters) +[System.Management.Automation.PowerShell.AddParameters*](/dotnet/api/System.Management.Automation.PowerShell.AddParameters) method. ```csharp @@ -93,13 +93,13 @@ PowerShell.Create().AddCommand("Get-Command") ### AddStatement You can simulate batching by using the -[System.Management.Automation.Powershell.Addstatement*](/dotnet/api/System.Management.Automation.PowerShell.AddStatement) +[System.Management.Automation.PowerShell.AddStatement*](/dotnet/api/System.Management.Automation.PowerShell.AddStatement) method, which adds an additional statement to the end of the pipeline The following code gets a list -of running processes with the name `PowerShell`, and then gets the list of running services. +of running processes with the name `powershell`, and then gets the list of running services. ```csharp PowerShell ps = PowerShell.Create(); -ps.AddCommand("Get-Process").AddParameter("Name", "PowerShell"); +ps.AddCommand("Get-Process").AddParameter("Name", "powershell"); ps.AddStatement().AddCommand("Get-Service"); ps.Invoke(); ``` @@ -107,7 +107,7 @@ ps.Invoke(); ### AddScript You can run an existing script by calling the -[System.Management.Automation.Powershell.Addscript*](/dotnet/api/System.Management.Automation.PowerShell.AddScript) +[System.Management.Automation.PowerShell.AddScript*](/dotnet/api/System.Management.Automation.PowerShell.AddScript) method. The following example adds a script to the pipeline and runs it. This example assumes there is already a script named `MyScript.ps1` in a folder named `D:\PSScripts`. @@ -117,7 +117,7 @@ ps.AddScript(File.ReadAllText(@"D:\PSScripts\MyScript.ps1")).Invoke(); ``` There is also a version of the -[System.Management.Automation.Powershell.Addscript*](/dotnet/api/System.Management.Automation.PowerShell.AddScript) +[System.Management.Automation.PowerShell.AddScript*](/dotnet/api/System.Management.Automation.PowerShell.AddScript) method that takes a boolean parameter named `useLocalScope`. If this parameter is set to `true`, then the script is run in the local scope. The following code will run the script in the local scope. @@ -131,7 +131,7 @@ ps.AddScript(File.ReadAllText(@"D:\PSScripts\MyScript.ps1"), true).Invoke(); After you add elements to the pipeline, you invoke it. To invoke the pipeline synchronously, you call an overload of the -[System.Management.Automation.Powershell.Invoke*](/dotnet/api/System.Management.Automation.PowerShell.Invoke) +[System.Management.Automation.PowerShell.Invoke*](/dotnet/api/System.Management.Automation.PowerShell.Invoke) method. The following example shows how to synchronously invoke a pipeline. ```csharp @@ -165,9 +165,9 @@ namespace HostPS1e ### Invoking a pipeline asynchronously You invoke a pipeline asynchronously by calling an overload of the -[System.Management.Automation.Powershell.Begininvoke*](/dotnet/api/System.Management.Automation.PowerShell.BeginInvoke) +[System.Management.Automation.PowerShell.BeginInvoke*](/dotnet/api/System.Management.Automation.PowerShell.BeginInvoke) to create an [IAsyncResult](/dotnet/api/system.iasyncresult) object, and then calling the -[System.Management.Automation.Powershell.Endinvoke*](/dotnet/api/System.Management.Automation.PowerShell.EndInvoke) +[System.Management.Automation.PowerShell.EndInvoke*](/dotnet/api/System.Management.Automation.PowerShell.EndInvoke) method. The following example shows how to invoke a pipeline asynchronously. diff --git a/reference/docs-conceptual/developer/hosting/creating-a-constrained-runspace.md b/reference/docs-conceptual/developer/hosting/creating-a-constrained-runspace.md index eeac94ee9980..8747646e1fbf 100644 --- a/reference/docs-conceptual/developer/hosting/creating-a-constrained-runspace.md +++ b/reference/docs-conceptual/developer/hosting/creating-a-constrained-runspace.md @@ -6,11 +6,11 @@ title: Creating a constrained runspace --- # Creating a constrained runspace -For performance or security reasons, you might want to restrict the Windows PowerShell commands available to your host application. To do this you create an empty [System.Management.Automation.Runspaces.Initialsessionstate](/dotnet/api/System.Management.Automation.Runspaces.InitialSessionState) by calling the [System.Management.Automation.Runspaces.Initialsessionstate.Create*](/dotnet/api/System.Management.Automation.Runspaces.InitialSessionState.Create) method, and then add only the commands you want available. +For performance or security reasons, you might want to restrict the Windows PowerShell commands available to your host application. To do this you create an empty [System.Management.Automation.Runspaces.InitialSessionState](/dotnet/api/System.Management.Automation.Runspaces.InitialSessionState) by calling the [System.Management.Automation.Runspaces.InitialSessionState.Create*](/dotnet/api/System.Management.Automation.Runspaces.InitialSessionState.Create) method, and then add only the commands you want available. Using a runspace that loads only the commands that you specify provides significantly improved performance. - You use the methods of the [System.Management.Automation.Runspaces.Sessionstatecmdletentry](/dotnet/api/System.Management.Automation.Runspaces.SessionStateCmdletEntry) class to define cmdlets for the initial session state. + You use the methods of the [System.Management.Automation.Runspaces.SessionStateCmdletEntry](/dotnet/api/System.Management.Automation.Runspaces.SessionStateCmdletEntry) class to define cmdlets for the initial session state. You can also make commands private. Private commands can be used by the host application, but not by users of the application. @@ -48,13 +48,13 @@ namespace Microsoft.Samples.PowerShell.Runspaces // Add the Get-Process and Get-Command cmdlets to the session state. SessionStateCmdletEntry ssce1 = new SessionStateCmdletEntry( - "get-process", + "Get-Process", typeof(GetProcessCommand), null); iss.Commands.Add(ssce1); SessionStateCmdletEntry ssce2 = new SessionStateCmdletEntry( - "get-command", + "Get-Command", typeof(GetCommandCommand), null); iss.Commands.Add(ssce2); @@ -68,7 +68,7 @@ namespace Microsoft.Samples.PowerShell.Runspaces powershell.Runspace = myRunSpace; // Create a pipeline with the Get-Command command. - powershell.AddCommand("get-command"); + powershell.AddCommand("Get-Command"); Collection results = powershell.Invoke(); @@ -98,11 +98,11 @@ namespace Microsoft.Samples.PowerShell.Runspaces ## Making commands private - You can also make a command private, by setting it's [System.Management.Automation.Commandinfo.Visibility](/dotnet/api/System.Management.Automation.CommandInfo.Visibility) property to [System.Management.Automation.SessionStateEntryVisibility](/dotnet/api/System.Management.Automation.SessionStateEntryVisibility) **Private**. The host application and other commands can call that command, but the user of the application cannot. In the following example, the [Get-ChildItem](/powershell/module/Microsoft.PowerShell.Management/Get-ChildItem) command is private. + You can also make a command private, by setting it's [System.Management.Automation.CommandInfo.Visibility](/dotnet/api/System.Management.Automation.CommandInfo.Visibility) property to [System.Management.Automation.SessionStateEntryVisibility](/dotnet/api/System.Management.Automation.SessionStateEntryVisibility) **Private**. The host application and other commands can call that command, but the user of the application cannot. In the following example, the [Get-ChildItem](/powershell/module/Microsoft.PowerShell.Management/Get-ChildItem) command is private. ```csharp defaultSessionState = InitialSessionState.CreateDefault(); -commandIndex = GetIndexOfEntry(defaultSessionState.Commands, "get-childitem"); +commandIndex = GetIndexOfEntry(defaultSessionState.Commands, "Get-ChildItem"); defaultSessionState.Commands[commandIndex].Visibility = SessionStateEntryVisibility.Private; this.runspace = RunspaceFactory.CreateRunspace(defaultSessionState); diff --git a/reference/docs-conceptual/developer/hosting/creating-a-custom-user-interface.md b/reference/docs-conceptual/developer/hosting/creating-a-custom-user-interface.md index 61679bb5e425..350cde81e054 100644 --- a/reference/docs-conceptual/developer/hosting/creating-a-custom-user-interface.md +++ b/reference/docs-conceptual/developer/hosting/creating-a-custom-user-interface.md @@ -6,4 +6,4 @@ title: Creating a custom user interface --- # Creating a custom user interface -Windows PowerShell provides abstract classes and interfaces that allow you to create a custom interactive UI that hosts the Windows PowerShell engine. To create a custom UI, you must implement the [System.Management.Automation.Host.PSHost](/dotnet/api/System.Management.Automation.Host.PSHost) class. Optionally, you can also implement the [System.Management.Automation.Host.Pshostrawuserinterface](/dotnet/api/System.Management.Automation.Host.PSHostRawUserInterface) and [System.Management.Automation.Host.Pshostuserinterface](/dotnet/api/System.Management.Automation.Host.PSHostUserInterface) classes, and the [System.Management.Automation.Host.Ihostsupportsinteractivesession](/dotnet/api/System.Management.Automation.Host.IHostSupportsInteractiveSession) and [System.Management.Automation.Host.Ihostuisupportsmultiplechoiceselection](/dotnet/api/System.Management.Automation.Host.IHostUISupportsMultipleChoiceSelection) interfaces. +Windows PowerShell provides abstract classes and interfaces that allow you to create a custom interactive UI that hosts the Windows PowerShell engine. To create a custom UI, you must implement the [System.Management.Automation.Host.PSHost](/dotnet/api/System.Management.Automation.Host.PSHost) class. Optionally, you can also implement the [System.Management.Automation.Host.PSHostRawUserInterface](/dotnet/api/System.Management.Automation.Host.PSHostRawUserInterface) and [System.Management.Automation.Host.PSHostUserInterface](/dotnet/api/System.Management.Automation.Host.PSHostUserInterface) classes, and the [System.Management.Automation.Host.IHostSupportsInteractiveSession](/dotnet/api/System.Management.Automation.Host.IHostSupportsInteractiveSession) and [System.Management.Automation.Host.IHostUISupportsMultipleChoiceSelection](/dotnet/api/System.Management.Automation.Host.IHostUISupportsMultipleChoiceSelection) interfaces. diff --git a/reference/docs-conceptual/developer/hosting/creating-multiple-runspaces.md b/reference/docs-conceptual/developer/hosting/creating-multiple-runspaces.md index 3841976c73a8..f462a725f592 100644 --- a/reference/docs-conceptual/developer/hosting/creating-multiple-runspaces.md +++ b/reference/docs-conceptual/developer/hosting/creating-multiple-runspaces.md @@ -6,7 +6,7 @@ title: Creating multiple runspaces --- # Creating multiple runspaces -If you create a large number of runspaces, you might consider creating a runspace pool. Using a [System.Management.Automation.Runspaces.Runspacepool](/dotnet/api/System.Management.Automation.Runspaces.RunspacePool) object, rather than creating a large number of individual runspaces with the same characteristics, can improve performance. +If you create a large number of runspaces, you might consider creating a runspace pool. Using a [System.Management.Automation.Runspaces.RunspacePool](/dotnet/api/System.Management.Automation.Runspaces.RunspacePool) object, rather than creating a large number of individual runspaces with the same characteristics, can improve performance. ## Creating and using a runspace pool. @@ -42,7 +42,7 @@ namespace HostRunspacePool rsp.Open(); // Create a PowerShell object to run the following command. - // get-process wmi* + // Get-Process wmi* PowerShell gpc = PowerShell.Create(); // Specify the runspace to use and add commands. gpc.RunspacePool = rsp; @@ -54,7 +54,7 @@ namespace HostRunspacePool PSDataCollection gpcOutput = gpc.EndInvoke(gpcAsyncResult); // Process the output. - Console.WriteLine("The output from running the command: get-process wmi*"); + Console.WriteLine("The output from running the command: Get-Process wmi*"); for (int i= 0; i < gpcOutput.Count; i++) { Console.WriteLine( diff --git a/reference/docs-conceptual/developer/hosting/creating-remote-runspaces.md b/reference/docs-conceptual/developer/hosting/creating-remote-runspaces.md index 0d36849400cc..fa44474b8ce0 100644 --- a/reference/docs-conceptual/developer/hosting/creating-remote-runspaces.md +++ b/reference/docs-conceptual/developer/hosting/creating-remote-runspaces.md @@ -75,7 +75,7 @@ namespace Samples using (PowerShell powershell = PowerShell.Create()) { powershell.Runspace = remoteRunspace; - powershell.AddCommand("get-process"); + powershell.AddCommand("Get-Process"); powershell.Invoke(); Collection results = powershell.Invoke(); diff --git a/reference/docs-conceptual/developer/hosting/creating-runspaces.md b/reference/docs-conceptual/developer/hosting/creating-runspaces.md index a325bb037182..3d9ef2bbc61c 100644 --- a/reference/docs-conceptual/developer/hosting/creating-runspaces.md +++ b/reference/docs-conceptual/developer/hosting/creating-runspaces.md @@ -8,7 +8,7 @@ title: Creating Runspaces A runspace is the operating environment for the commands that are invoked by a host application. This environment includes the commands and data that are currently present, and any language restrictions that currently apply. - Host applications can use the default runspace that is provided by Windows PowerShell, which includes all available core commands, or create a custom runspace that includes only a subset of the available commands. To create a customized runspace, you create a [System.Management.Automation.Runspaces.Initialsessionstate](/dotnet/api/System.Management.Automation.Runspaces.InitialSessionState) object and assign it to your runspace. + Host applications can use the default runspace that is provided by Windows PowerShell, which includes all available core commands, or create a custom runspace that includes only a subset of the available commands. To create a customized runspace, you create a [System.Management.Automation.Runspaces.InitialSessionState](/dotnet/api/System.Management.Automation.Runspaces.InitialSessionState) object and assign it to your runspace. ## Runspace tasks diff --git a/reference/docs-conceptual/developer/hosting/custom-host-samples.md b/reference/docs-conceptual/developer/hosting/custom-host-samples.md index b13199e4d881..75f1d3bb1421 100644 --- a/reference/docs-conceptual/developer/hosting/custom-host-samples.md +++ b/reference/docs-conceptual/developer/hosting/custom-host-samples.md @@ -23,7 +23,7 @@ This section includes sample code for writing a custom host. You can use Microso This sample shows how to build an interactive console-based host application that reads commands from the command line, executes the commands, and then displays the results to the console. This host application also supports displaying prompts that allow the user to specify multiple choices. [Host05 Sample](./host05-sample.md) - This sample shows how to build an interactive console-based host application that reads commands from the command line, executes the commands, and then displays the results to the console. This host application also supports calls to remote computers by using the [Enter-PsSession](/powershell/module/Microsoft.PowerShell.Core/Enter-PSSession) and [Exit-PsSession](/powershell/module/Microsoft.PowerShell.Core/Exit-PSSession) cmdlets + This sample shows how to build an interactive console-based host application that reads commands from the command line, executes the commands, and then displays the results to the console. This host application also supports calls to remote computers by using the [Enter-PSSession](/powershell/module/Microsoft.PowerShell.Core/Enter-PSSession) and [Exit-PSSession](/powershell/module/Microsoft.PowerShell.Core/Exit-PSSession) cmdlets [Host06 Sample](./host06-sample.md) This sample shows how to build an interactive console-based host application that reads commands from the command line, executes the commands, and then displays the results to the console. In addition, this sample uses the Tokenizer APIs to specify the color of the text that is entered by the user. diff --git a/reference/docs-conceptual/developer/hosting/host01-sample.md b/reference/docs-conceptual/developer/hosting/host01-sample.md index f1c4d1120d1f..66ec6d5a6091 100644 --- a/reference/docs-conceptual/developer/hosting/host01-sample.md +++ b/reference/docs-conceptual/developer/hosting/host01-sample.md @@ -8,7 +8,7 @@ title: Host01 Sample This sample shows how to implement a host application that uses a custom host. In this sample a runspace is created that uses the custom host, and then the -[System.Management.Automation.Powershell](/dotnet/api/System.Management.Automation.PowerShell) API +[System.Management.Automation.PowerShell](/dotnet/api/System.Management.Automation.PowerShell) API is used to run a script that calls "exit." The host application then looks at the output of the script and prints out the results. @@ -28,7 +28,7 @@ This sample requires Windows PowerShell 2.0. - Creating a runspace that uses the custom host class. - Creating a - [System.Management.Automation.Powershell](/dotnet/api/System.Management.Automation.PowerShell) + [System.Management.Automation.PowerShell](/dotnet/api/System.Management.Automation.PowerShell) object that runs a script that calls exit. - Verifying that the correct exit code was used in the exit process. diff --git a/reference/docs-conceptual/developer/hosting/host02-sample.md b/reference/docs-conceptual/developer/hosting/host02-sample.md index 8db7c6aef344..17e458707dd1 100644 --- a/reference/docs-conceptual/developer/hosting/host02-sample.md +++ b/reference/docs-conceptual/developer/hosting/host02-sample.md @@ -31,7 +31,7 @@ This sample requires Windows PowerShell 2.0. - Setting the host culture to German. - Creating a - [System.Management.Automation.Powershell](/dotnet/api/system.management.automation.powershell) + [System.Management.Automation.PowerShell](/dotnet/api/system.management.automation.powershell) object that runs a script to retrieve and sort the processes, then retrieves the current date which is displayed in German. @@ -84,7 +84,7 @@ namespace Microsoft.Samples.PowerShell.Host /// /// This sample uses the PowerShell runtime along with a host - /// implementation to call get-process and display the results + /// implementation to call Get-Process and display the results /// as you would see them in powershell.exe. /// /// Ignored @@ -110,9 +110,9 @@ namespace Microsoft.Samples.PowerShell.Host // date displayed in German. pipe.Commands.AddScript(@" - get-process | sort handlecount + Get-Process | sort HandleCount # This should display the date in German... - get-date | out-string + Get-Date | Out-String "); // Add the default outputter to the end of the pipe and indicate @@ -120,7 +120,7 @@ namespace Microsoft.Samples.PowerShell.Host // commands. This will result in the output being written using the PSHost // and PSHostUserInterface classes instead of returning objects to the hosting // application. - pipe.Commands.Add("out-default"); + pipe.Commands.Add("Out-Default"); pipe.Commands[0].MergeMyResults(PipelineResultTypes.Error,PipelineResultTypes.Output); // Invoke the pipeline. There will not be any objects @@ -796,10 +796,10 @@ namespace Microsoft.Samples.PowerShell.Host ## See Also - [System.Management.Automation.Powershell](/dotnet/api/system.management.automation.powershell) + [System.Management.Automation.PowerShell](/dotnet/api/system.management.automation.powershell) [System.Management.Automation.Host.PSHost](/dotnet/api/System.Management.Automation.Host.PSHost) - [System.Management.Automation.Host.Pshostuserinterface](/dotnet/api/System.Management.Automation.Host.PSHostUserInterface) + [System.Management.Automation.Host.PSHostUserInterface](/dotnet/api/System.Management.Automation.Host.PSHostUserInterface) - [System.Management.Automation.Host.Pshostrawuserinterface](/dotnet/api/System.Management.Automation.Host.PSHostRawUserInterface) + [System.Management.Automation.Host.PSHostRawUserInterface](/dotnet/api/System.Management.Automation.Host.PSHostRawUserInterface) diff --git a/reference/docs-conceptual/developer/hosting/host03-sample.md b/reference/docs-conceptual/developer/hosting/host03-sample.md index cc5d52eca61d..e1230b5ad8ce 100644 --- a/reference/docs-conceptual/developer/hosting/host03-sample.md +++ b/reference/docs-conceptual/developer/hosting/host03-sample.md @@ -155,7 +155,7 @@ namespace Microsoft.Samples.PowerShell.Host // commands. This will result in the output being written using the PSHost // and PSHostUserInterface classes instead of returning objects to the hosting // application. - this.currentPowerShell.AddCommand("out-default"); + this.currentPowerShell.AddCommand("Out-Default"); this.currentPowerShell.Commands.Commands[0].MergeMyResults(PipelineResultTypes.Error, PipelineResultTypes.Output); // If there was any input specified, pass it in, otherwise just @@ -185,7 +185,7 @@ namespace Microsoft.Samples.PowerShell.Host /// using the display formatter. To do this we run /// a second pipeline passing in the error record. /// The runtime will bind this to the $input variable - /// which is why $input is being piped to out-string. + /// which is why $input is being piped to Out-String. /// We then call WriteErrorLine to make sure the error /// gets displayed in the correct error color. @@ -214,7 +214,7 @@ namespace Microsoft.Samples.PowerShell.Host try { - this.currentPowerShell.AddScript("$input").AddCommand("out-string"); + this.currentPowerShell.AddScript("$input").AddCommand("Out-String"); // Do not merge errors, this function will swallow errors. Collection result; @@ -228,7 +228,7 @@ namespace Microsoft.Samples.PowerShell.Host string str = result[0].BaseObject as string; if (!string.IsNullOrEmpty(str)) { - // Remove \r\n that is added by Out-string. + // Remove \r\n that is added by Out-String. this.myHost.UI.WriteErrorLine(str.Substring(0, str.Length - 2)); } } @@ -435,7 +435,7 @@ namespace Microsoft.Samples.PowerShell.Host // commands. This will result in the output being written using the PSHost // and PSHostUserInterface classes instead of returning objects to the hosting // application. - currentPipeline.Commands.Add("out-default"); + currentPipeline.Commands.Add("Out-Default"); currentPipeline.Commands[0].MergeMyResults(PipelineResultTypes.Error, PipelineResultTypes.Output); // If there was any input specified, pass it in, otherwise just @@ -479,8 +479,8 @@ namespace Microsoft.Samples.PowerShell.Host // using the display formatter. To do this we run // a second pipeline passing in the error record. // The runtime will bind this to the $input variable - // which is why $input is being piped to out-default - executeHelper("$input | out-default", rte.ErrorRecord); + // which is why $input is being piped to Out-Default + executeHelper("$input | Out-Default", rte.ErrorRecord); } } @@ -1185,6 +1185,6 @@ namespace Microsoft.Samples.PowerShell.Host [System.Management.Automation.Host.PSHost](/dotnet/api/System.Management.Automation.Host.PSHost) - [System.Management.Automation.Host.Pshostuserinterface](/dotnet/api/System.Management.Automation.Host.PSHostUserInterface) + [System.Management.Automation.Host.PSHostUserInterface](/dotnet/api/System.Management.Automation.Host.PSHostUserInterface) - [System.Management.Automation.Host.Pshostrawuserinterface](/dotnet/api/System.Management.Automation.Host.PSHostRawUserInterface) + [System.Management.Automation.Host.PSHostRawUserInterface](/dotnet/api/System.Management.Automation.Host.PSHostRawUserInterface) diff --git a/reference/docs-conceptual/developer/hosting/host04-sample.md b/reference/docs-conceptual/developer/hosting/host04-sample.md index 651b174bd100..eba8d2e5e8f9 100644 --- a/reference/docs-conceptual/developer/hosting/host04-sample.md +++ b/reference/docs-conceptual/developer/hosting/host04-sample.md @@ -213,7 +213,7 @@ namespace Microsoft.Samples.PowerShell.Host // commands. This will result in the output being written using the PSHost // and PSHostUserInterface classes instead of returning objects to the hosting // application. - this.currentPowerShell.AddCommand("out-default"); + this.currentPowerShell.AddCommand("Out-Default"); this.currentPowerShell.Commands.Commands[0].MergeMyResults(PipelineResultTypes.Error, PipelineResultTypes.Output); // If there was any input specified, pass it in, otherwise just @@ -244,7 +244,7 @@ namespace Microsoft.Samples.PowerShell.Host /// using the display formatter. To do this we run /// a second pipeline passing in the error record. /// The runtime will bind this to the $input variable - /// which is why $input is being piped to out-string. + /// which is why $input is being piped to Out-String. /// We then call WriteErrorLine to make sure the error /// gets displayed in the correct error color. /// @@ -273,7 +273,7 @@ namespace Microsoft.Samples.PowerShell.Host try { - this.currentPowerShell.AddScript("$input").AddCommand("out-string"); + this.currentPowerShell.AddScript("$input").AddCommand("Out-String"); // Do not merge errors, this function will swallow errors. Collection result; @@ -287,7 +287,7 @@ namespace Microsoft.Samples.PowerShell.Host string str = result[0].BaseObject as string; if (!string.IsNullOrEmpty(str)) { - // Remove \r\n that is added by out-string. + // Remove \r\n that is added by Out-String. this.myHost.UI.WriteErrorLine(str.Substring(0, str.Length - 2)); } } @@ -566,7 +566,7 @@ namespace Microsoft.Samples.PowerShell.Host ## Example 3 The following code is the implementation of the -[System.Management.Automation.Host.Pshostuserinterface](/dotnet/api/System.Management.Automation.Host.PSHostUserInterface) +[System.Management.Automation.Host.PSHostUserInterface](/dotnet/api/System.Management.Automation.Host.PSHostUserInterface) class that is used by this host application. ```csharp @@ -1086,7 +1086,7 @@ namespace Microsoft.Samples.PowerShell.Host ## Example 4 The following code is the implementation of the -[System.Management.Automation.Host.Pshostrawuserinterface](/dotnet/api/System.Management.Automation.Host.PSHostRawUserInterface) +[System.Management.Automation.Host.PSHostRawUserInterface](/dotnet/api/System.Management.Automation.Host.PSHostRawUserInterface) class that is used by this host application. Those elements that are not implemented throw an exception or return nothing. @@ -1302,6 +1302,6 @@ namespace Microsoft.Samples.PowerShell.Host [System.Management.Automation.Host.PSHost](/dotnet/api/System.Management.Automation.Host.PSHost) - [System.Management.Automation.Host.Pshostuserinterface](/dotnet/api/System.Management.Automation.Host.PSHostUserInterface) + [System.Management.Automation.Host.PSHostUserInterface](/dotnet/api/System.Management.Automation.Host.PSHostUserInterface) - [System.Management.Automation.Host.Pshostrawuserinterface](/dotnet/api/System.Management.Automation.Host.PSHostRawUserInterface) + [System.Management.Automation.Host.PSHostRawUserInterface](/dotnet/api/System.Management.Automation.Host.PSHostRawUserInterface) diff --git a/reference/docs-conceptual/developer/hosting/host05-sample.md b/reference/docs-conceptual/developer/hosting/host05-sample.md index 7387f75a9c6a..ba539d59509d 100644 --- a/reference/docs-conceptual/developer/hosting/host05-sample.md +++ b/reference/docs-conceptual/developer/hosting/host05-sample.md @@ -9,8 +9,8 @@ title: Host05 Sample This sample shows how to build an interactive console-based host application that reads commands from the command line, executes the commands, and then displays the results to the console. This host application also supports calls to remote computers by using the -[Enter-PsSession](/powershell/module/Microsoft.PowerShell.Core/Enter-PSSession) and -[Exit-PsSession](/powershell/module/Microsoft.PowerShell.Core/Exit-PSSession) cmdlets. +[Enter-PSSession](/powershell/module/Microsoft.PowerShell.Core/Enter-PSSession) and +[Exit-PSSession](/powershell/module/Microsoft.PowerShell.Core/Exit-PSSession) cmdlets. ## Requirements @@ -23,9 +23,9 @@ host application also supports calls to remote computers by using the - Creating a custom host whose classes derive from the [System.Management.Automation.Host.PSHost](/dotnet/api/System.Management.Automation.Host.PSHost) class, the - [System.Management.Automation.Host.Pshostuserinterface](/dotnet/api/System.Management.Automation.Host.PSHostUserInterface) + [System.Management.Automation.Host.PSHostUserInterface](/dotnet/api/System.Management.Automation.Host.PSHostUserInterface) class, and the - [System.Management.Automation.Host.Pshostrawuserinterface](/dotnet/api/System.Management.Automation.Host.PSHostRawUserInterface) + [System.Management.Automation.Host.PSHostRawUserInterface](/dotnet/api/System.Management.Automation.Host.PSHostRawUserInterface) class. - Building a console application that uses these host classes to build an interactive Windows PowerShell shell. @@ -44,8 +44,8 @@ host application also supports calls to remote computers by using the - Implement the [System.Management.Automation.Host.IHostSupportsInteractiveSession](/dotnet/api/System.Management.Automation.Host.IHostSupportsInteractiveSession) interface to support interactive remoting by using the - [Enter-PsSession](/powershell/module/Microsoft.PowerShell.Core/Enter-PSSession) and - [Exit-PsSession](/powershell/module/Microsoft.PowerShell.Core/Exit-PSSession) cmdlets. + [Enter-PSSession](/powershell/module/Microsoft.PowerShell.Core/Enter-PSSession) and + [Exit-PSSession](/powershell/module/Microsoft.PowerShell.Core/Exit-PSSession) cmdlets. ## Example 1 @@ -226,7 +226,7 @@ namespace Microsoft.Samples.PowerShell.Host // error streams from the pipeline. This will result in the // output being written using the PSHost and PSHostUserInterface // classes instead of returning objects to the host application. - this.currentPowerShell.AddCommand("out-default"); + this.currentPowerShell.AddCommand("Out-Default"); this.currentPowerShell.Commands.Commands[0].MergeMyResults(PipelineResultTypes.Error, PipelineResultTypes.Output); // If there is any input pass it in, otherwise just invoke the @@ -286,7 +286,7 @@ namespace Microsoft.Samples.PowerShell.Host try { - this.currentPowerShell.AddScript("$input").AddCommand("out-string"); + this.currentPowerShell.AddScript("$input").AddCommand("Out-String"); // Do not merge errors, this function will swallow errors. Collection result; @@ -643,7 +643,7 @@ namespace Microsoft.Samples.PowerShell.Host ## Example 3 The following code is the implementation of the -[System.Management.Automation.Host.Pshostuserinterface](/dotnet/api/System.Management.Automation.Host.PSHostUserInterface) +[System.Management.Automation.Host.PSHostUserInterface](/dotnet/api/System.Management.Automation.Host.PSHostUserInterface) class that is used by this host application. ```csharp @@ -1164,7 +1164,7 @@ namespace Microsoft.Samples.PowerShell.Host ## Example 4 The following code is the implementation of the -[System.Management.Automation.Host.Pshostrawuserinterface](/dotnet/api/System.Management.Automation.Host.PSHostRawUserInterface) +[System.Management.Automation.Host.PSHostRawUserInterface](/dotnet/api/System.Management.Automation.Host.PSHostRawUserInterface) class that is used by this host application. Those elements that are not implemented throw an exception or return nothing. @@ -1380,6 +1380,6 @@ namespace Microsoft.Samples.PowerShell.Host [System.Management.Automation.Host.PSHost](/dotnet/api/System.Management.Automation.Host.PSHost) - [System.Management.Automation.Host.Pshostuserinterface](/dotnet/api/System.Management.Automation.Host.PSHostUserInterface) + [System.Management.Automation.Host.PSHostUserInterface](/dotnet/api/System.Management.Automation.Host.PSHostUserInterface) - [System.Management.Automation.Host.Pshostrawuserinterface](/dotnet/api/System.Management.Automation.Host.PSHostRawUserInterface) + [System.Management.Automation.Host.PSHostRawUserInterface](/dotnet/api/System.Management.Automation.Host.PSHostRawUserInterface) diff --git a/reference/docs-conceptual/developer/hosting/host06-sample.md b/reference/docs-conceptual/developer/hosting/host06-sample.md index 1b53bf7767c2..3bc856f117a4 100644 --- a/reference/docs-conceptual/developer/hosting/host06-sample.md +++ b/reference/docs-conceptual/developer/hosting/host06-sample.md @@ -21,9 +21,9 @@ the user. - Creating a custom host whose classes derive from the [System.Management.Automation.Host.PSHost](/dotnet/api/System.Management.Automation.Host.PSHost) class, the - [System.Management.Automation.Host.Pshostuserinterface](/dotnet/api/System.Management.Automation.Host.PSHostUserInterface) + [System.Management.Automation.Host.PSHostUserInterface](/dotnet/api/System.Management.Automation.Host.PSHostUserInterface) class, and the - [System.Management.Automation.Host.Pshostrawuserinterface](/dotnet/api/System.Management.Automation.Host.PSHostRawUserInterface) + [System.Management.Automation.Host.PSHostRawUserInterface](/dotnet/api/System.Management.Automation.Host.PSHostRawUserInterface) class. - Building a console application that uses these host classes to build an interactive Windows @@ -43,8 +43,8 @@ the user. - Implement the [System.Management.Automation.Host.IHostSupportsInteractiveSession](/dotnet/api/System.Management.Automation.Host.IHostSupportsInteractiveSession) interface to support interactive remoting by using the - [Enter-PsSession](/powershell/module/Microsoft.PowerShell.Core/Enter-PSSession) and - [Exit-PsSession](/powershell/module/Microsoft.PowerShell.Core/Exit-PSSession) cmdlets. + [Enter-PSSession](/powershell/module/Microsoft.PowerShell.Core/Enter-PSSession) and + [Exit-PSSession](/powershell/module/Microsoft.PowerShell.Core/Exit-PSSession) cmdlets. - Use the Tokenize API to colorize the command line as it is typed. @@ -234,7 +234,7 @@ namespace Microsoft.Samples.PowerShell.Host // pipeline. This will result in the output being written using the PSHost // and PSHostUserInterface classes instead of returning objects to the host // application. - this.currentPowerShell.AddCommand("out-default"); + this.currentPowerShell.AddCommand("Out-Default"); this.currentPowerShell.Commands.Commands[0].MergeMyResults(PipelineResultTypes.Error, PipelineResultTypes.Output); // If there is any input pass it in, otherwise just invoke the @@ -294,7 +294,7 @@ namespace Microsoft.Samples.PowerShell.Host try { - this.currentPowerShell.AddScript("$input").AddCommand("out-string"); + this.currentPowerShell.AddScript("$input").AddCommand("Out-String"); // Do not merge errors, this function will swallow errors. Collection result; @@ -642,7 +642,7 @@ namespace Microsoft.Samples.PowerShell.Host ## Example 3 The following code is the implementation of the -[System.Management.Automation.Host.Pshostuserinterface](/dotnet/api/System.Management.Automation.Host.PSHostUserInterface) +[System.Management.Automation.Host.PSHostUserInterface](/dotnet/api/System.Management.Automation.Host.PSHostUserInterface) class that is used by this host application. ```csharp @@ -1162,7 +1162,7 @@ namespace Microsoft.Samples.PowerShell.Host ## Example 4 The following code is the implementation of the -[System.Management.Automation.Host.Pshostrawuserinterface](/dotnet/api/System.Management.Automation.Host.PSHostRawUserInterface) +[System.Management.Automation.Host.PSHostRawUserInterface](/dotnet/api/System.Management.Automation.Host.PSHostRawUserInterface) class that is used by this host application. Those elements that are not implemented throw an exception or return nothing. @@ -1378,7 +1378,7 @@ namespace Microsoft.Samples.PowerShell.Host The following code reads the command line and colors the text as it is entered. Tokens are determined by using the -[System.Management.Automation.Psparser.Tokenize*](/dotnet/api/System.Management.Automation.PSParser.Tokenize) +[System.Management.Automation.PSParser.Tokenize*](/dotnet/api/System.Management.Automation.PSParser.Tokenize) method. ```csharp @@ -1862,6 +1862,6 @@ namespace Microsoft.Samples.PowerShell.Host [System.Management.Automation.Host.PSHost](/dotnet/api/System.Management.Automation.Host.PSHost) - [System.Management.Automation.Host.Pshostuserinterface](/dotnet/api/System.Management.Automation.Host.PSHostUserInterface) + [System.Management.Automation.Host.PSHostUserInterface](/dotnet/api/System.Management.Automation.Host.PSHostUserInterface) - [System.Management.Automation.Host.Pshostrawuserinterface](/dotnet/api/System.Management.Automation.Host.PSHostRawUserInterface) + [System.Management.Automation.Host.PSHostRawUserInterface](/dotnet/api/System.Management.Automation.Host.PSHostRawUserInterface) diff --git a/reference/docs-conceptual/developer/hosting/remoterunspace01-sample.md b/reference/docs-conceptual/developer/hosting/remoterunspace01-sample.md index e70ca026de30..f9c0bdc27a8d 100644 --- a/reference/docs-conceptual/developer/hosting/remoterunspace01-sample.md +++ b/reference/docs-conceptual/developer/hosting/remoterunspace01-sample.md @@ -14,11 +14,11 @@ This sample shows how to create a remote runspace that is used to establish a re ## Demonstrates -- Creating a [System.Management.Automation.Runspaces.Wsmanconnectioninfo](/dotnet/api/System.Management.Automation.Runspaces.WSManConnectionInfo) object. +- Creating a [System.Management.Automation.Runspaces.WSManConnectionInfo](/dotnet/api/System.Management.Automation.Runspaces.WSManConnectionInfo) object. -- Setting the [System.Management.Automation.Runspaces.Runspaceconnectioninfo.Operationtimeout*](/dotnet/api/System.Management.Automation.Runspaces.RunspaceConnectionInfo.OperationTimeout) and [System.Management.Automation.Runspaces.Runspaceconnectioninfo.Opentimeout*](/dotnet/api/System.Management.Automation.Runspaces.RunspaceConnectionInfo.OpenTimeout) properties of the [System.Management.Automation.Runspaces.Wsmanconnectioninfo](/dotnet/api/System.Management.Automation.Runspaces.WSManConnectionInfo) object. +- Setting the [System.Management.Automation.Runspaces.RunspaceConnectionInfo.OperationTimeout*](/dotnet/api/System.Management.Automation.Runspaces.RunspaceConnectionInfo.OperationTimeout) and [System.Management.Automation.Runspaces.RunspaceConnectionInfo.OpenTimeout*](/dotnet/api/System.Management.Automation.Runspaces.RunspaceConnectionInfo.OpenTimeout) properties of the [System.Management.Automation.Runspaces.WSManConnectionInfo](/dotnet/api/System.Management.Automation.Runspaces.WSManConnectionInfo) object. -- Creating a remote runspace that uses the [System.Management.Automation.Runspaces.Wsmanconnectioninfo](/dotnet/api/System.Management.Automation.Runspaces.WSManConnectionInfo) object to establish the remote connection. +- Creating a remote runspace that uses the [System.Management.Automation.Runspaces.WSManConnectionInfo](/dotnet/api/System.Management.Automation.Runspaces.WSManConnectionInfo) object to establish the remote connection. - Closing the remote runspace to release the remote connection. diff --git a/reference/docs-conceptual/developer/hosting/remoterunspacepool01-sample.md b/reference/docs-conceptual/developer/hosting/remoterunspacepool01-sample.md index 7d95273bf051..19ec0ab54728 100644 --- a/reference/docs-conceptual/developer/hosting/remoterunspacepool01-sample.md +++ b/reference/docs-conceptual/developer/hosting/remoterunspacepool01-sample.md @@ -14,11 +14,11 @@ This sample shows how to construct a remote runspace pool and how to run multipl ## Demonstrates -- Creating a [System.Management.Automation.Runspaces.Wsmanconnectioninfo](/dotnet/api/System.Management.Automation.Runspaces.WSManConnectionInfo) object. +- Creating a [System.Management.Automation.Runspaces.WSManConnectionInfo](/dotnet/api/System.Management.Automation.Runspaces.WSManConnectionInfo) object. -- Setting the [System.Management.Automation.Runspaces.Runspaceconnectioninfo.Operationtimeout*](/dotnet/api/System.Management.Automation.Runspaces.RunspaceConnectionInfo.OperationTimeout) and [System.Management.Automation.Runspaces.Runspaceconnectioninfo.Opentimeout*](/dotnet/api/System.Management.Automation.Runspaces.RunspaceConnectionInfo.OpenTimeout) properties of the [System.Management.Automation.Runspaces.Wsmanconnectioninfo](/dotnet/api/System.Management.Automation.Runspaces.WSManConnectionInfo) object. +- Setting the [System.Management.Automation.Runspaces.RunspaceConnectionInfo.OperationTimeout*](/dotnet/api/System.Management.Automation.Runspaces.RunspaceConnectionInfo.OperationTimeout) and [System.Management.Automation.Runspaces.RunspaceConnectionInfo.OpenTimeout*](/dotnet/api/System.Management.Automation.Runspaces.RunspaceConnectionInfo.OpenTimeout) properties of the [System.Management.Automation.Runspaces.WSManConnectionInfo](/dotnet/api/System.Management.Automation.Runspaces.WSManConnectionInfo) object. -- Creating a remote runspace that uses the [System.Management.Automation.Runspaces.Wsmanconnectioninfo](/dotnet/api/System.Management.Automation.Runspaces.WSManConnectionInfo) object to establish the remote connection. +- Creating a remote runspace that uses the [System.Management.Automation.Runspaces.WSManConnectionInfo](/dotnet/api/System.Management.Automation.Runspaces.WSManConnectionInfo) object to establish the remote connection. - Running the [Get-Process](/powershell/module/Microsoft.PowerShell.Management/Get-Process) and [Get-Service](/powershell/module/microsoft.powershell.management/get-service) cmdlets concurrently by using the remote runspace pool. @@ -42,7 +42,7 @@ namespace Samples { /// /// This sample shows how to construct a remote RunspacePool and how to - /// concurrently run the get-process and get-service commands using the + /// concurrently run the Get-Process and Get-Service commands using the /// runspaces of the pool. /// /// Parameter is not used. @@ -66,16 +66,16 @@ namespace Samples remoteRunspacePool.Open(); // Call the Create() method to create a pipeline, call the AddCommand(string) - // method to add the "get-process" command, and then call the BeginInvoke() + // method to add the "Get-Process" command, and then call the BeginInvoke() // method to run the command asynchronously using a runspace of the pool. - PowerShell gpsCommand = PowerShell.Create().AddCommand("get-process"); + PowerShell gpsCommand = PowerShell.Create().AddCommand("Get-Process"); gpsCommand.RunspacePool = remoteRunspacePool; IAsyncResult gpsCommandAsyncResult = gpsCommand.BeginInvoke(); // The previous call does not block the current thread because it is // running asynchronously. Because the remote runspace pool can open two // runspaces, the second command can be run. - PowerShell getServiceCommand = PowerShell.Create().AddCommand("get-service"); + PowerShell getServiceCommand = PowerShell.Create().AddCommand("Get-Service"); getServiceCommand.RunspacePool = remoteRunspacePool; IAsyncResult getServiceCommandAsyncResult = getServiceCommand.BeginInvoke(); @@ -87,7 +87,7 @@ namespace Samples // Process the output from the first command. if ((gpsCommandOutput != null) && (gpsCommandOutput.Count > 0)) { - Console.WriteLine("The first output from running get-process command: "); + Console.WriteLine("The first output from running Get-Process command: "); Console.WriteLine( "Process Name: {0} Process Id: {1}", gpsCommandOutput[0].Properties["ProcessName"].Value, @@ -103,7 +103,7 @@ namespace Samples // Process the output of the second command as needed. if ((getServiceCommandOutput != null) && (getServiceCommandOutput.Count > 0)) { - Console.WriteLine("The first output from running get-service command: "); + Console.WriteLine("The first output from running Get-Service command: "); Console.WriteLine( "Service Name: {0} Description: {1} State: {2}", getServiceCommandOutput[0].Properties["ServiceName"].Value, diff --git a/reference/docs-conceptual/developer/hosting/runspace01-sample.md b/reference/docs-conceptual/developer/hosting/runspace01-sample.md index d098e2e313c6..77819976ad59 100644 --- a/reference/docs-conceptual/developer/hosting/runspace01-sample.md +++ b/reference/docs-conceptual/developer/hosting/runspace01-sample.md @@ -6,7 +6,7 @@ title: Runspace01 Sample --- # Runspace01 Sample -This sample shows how to use the [System.Management.Automation.Powershell](/dotnet/api/system.management.automation.powershell) class to run the [Get-Process](/powershell/module/Microsoft.PowerShell.Management/Get-Process) cmdlet synchronously. The [Get-Process](/powershell/module/Microsoft.PowerShell.Management/Get-Process) cmdlet returns [System.Diagnostics.Process](/dotnet/api/System.Diagnostics.Process) objects for each process running on the local computer. The values of the [System.Diagnostics.Process.Processname*](/dotnet/api/System.Diagnostics.Process.ProcessName) and [System.Diagnostics.Process.Handlecount*](/dotnet/api/System.Diagnostics.Process.Handlecount) properties are then extracted from the returned objects and displayed in a console window. +This sample shows how to use the [System.Management.Automation.PowerShell](/dotnet/api/system.management.automation.powershell) class to run the [Get-Process](/powershell/module/Microsoft.PowerShell.Management/Get-Process) cmdlet synchronously. The [Get-Process](/powershell/module/Microsoft.PowerShell.Management/Get-Process) cmdlet returns [System.Diagnostics.Process](/dotnet/api/System.Diagnostics.Process) objects for each process running on the local computer. The values of the [System.Diagnostics.Process.ProcessName*](/dotnet/api/System.Diagnostics.Process.ProcessName) and [System.Diagnostics.Process.HandleCount*](/dotnet/api/System.Diagnostics.Process.HandleCount) properties are then extracted from the returned objects and displayed in a console window. ## Requirements @@ -14,9 +14,9 @@ This sample shows how to use the [System.Management.Automation.Powershell](/dotn ## Demonstrates -- Creating a [System.Management.Automation.Powershell](/dotnet/api/system.management.automation.powershell) object to run a command. +- Creating a [System.Management.Automation.PowerShell](/dotnet/api/system.management.automation.powershell) object to run a command. -- Adding a command to the pipeline of the [System.Management.Automation.Powershell](/dotnet/api/system.management.automation.powershell) object. +- Adding a command to the pipeline of the [System.Management.Automation.PowerShell](/dotnet/api/system.management.automation.powershell) object. - Running the command synchronously. @@ -40,7 +40,7 @@ namespace Microsoft.Samples.PowerShell.Runspaces { /// /// This sample uses the PowerShell class to execute - /// the get-process cmdlet synchronously. The name and + /// the Get-Process cmdlet synchronously. The name and /// handlecount are then extracted from the PSObjects /// returned and displayed. /// @@ -57,7 +57,7 @@ namespace Microsoft.Samples.PowerShell.Runspaces { // Create a PowerShell object. Creating this object takes care of // building all of the other data structures needed to run the command. - using (PowerShell powershell = PowerShell.Create().AddCommand("get-process")) + using (PowerShell powershell = PowerShell.Create().AddCommand("Get-Process")) { Console.WriteLine("Process HandleCount"); Console.WriteLine("--------------------------------"); diff --git a/reference/docs-conceptual/developer/hosting/runspace02-sample.md b/reference/docs-conceptual/developer/hosting/runspace02-sample.md index 5c0a5846675b..cc98b2f88395 100644 --- a/reference/docs-conceptual/developer/hosting/runspace02-sample.md +++ b/reference/docs-conceptual/developer/hosting/runspace02-sample.md @@ -6,7 +6,7 @@ title: Runspace02 Sample --- # Runspace02 Sample -This sample shows how to use the [System.Management.Automation.Powershell](/dotnet/api/system.management.automation.powershell) class to run the [Get-Process](/powershell/module/Microsoft.PowerShell.Management/Get-Process) and [Sort-Object](/powershell/module/Microsoft.PowerShell.Utility/Sort-Object) cmdlets synchronously. The [Get-Process](/powershell/module/Microsoft.PowerShell.Management/Get-Process) cmdlet returns [System.Diagnostics.Process](/dotnet/api/System.Diagnostics.Process) objects for each process running on the local computer, and the `Sort-Object` sorts the objects based on their [System.Diagnostics.Process.Id*](/dotnet/api/System.Diagnostics.Process.Id) property. The results of these commands is displayed by using a [System.Windows.Forms.Datagridview](/dotnet/api/System.Windows.Forms.DataGridView) control. +This sample shows how to use the [System.Management.Automation.PowerShell](/dotnet/api/system.management.automation.powershell) class to run the [Get-Process](/powershell/module/Microsoft.PowerShell.Management/Get-Process) and [Sort-Object](/powershell/module/Microsoft.PowerShell.Utility/Sort-Object) cmdlets synchronously. The [Get-Process](/powershell/module/Microsoft.PowerShell.Management/Get-Process) cmdlet returns [System.Diagnostics.Process](/dotnet/api/System.Diagnostics.Process) objects for each process running on the local computer, and the `Sort-Object` sorts the objects based on their [System.Diagnostics.Process.Id*](/dotnet/api/System.Diagnostics.Process.Id) property. The results of these commands is displayed by using a [System.Windows.Forms.DataGridView](/dotnet/api/System.Windows.Forms.DataGridView) control. ## Requirements @@ -16,17 +16,17 @@ This sample requires Windows PowerShell 2.0. This sample demonstrates the following. -- Creating a [System.Management.Automation.Powershell](/dotnet/api/system.management.automation.powershell) object to run commands. +- Creating a [System.Management.Automation.PowerShell](/dotnet/api/system.management.automation.powershell) object to run commands. -- Adding commands to the pipeline of [System.Management.Automation.Powershell](/dotnet/api/system.management.automation.powershell) object. +- Adding commands to the pipeline of [System.Management.Automation.PowerShell](/dotnet/api/system.management.automation.powershell) object. - Running the commands synchronously. -- Using a [System.Windows.Forms.Datagridview](/dotnet/api/System.Windows.Forms.DataGridView) control to display the output of the commands in a Windows Forms application. +- Using a [System.Windows.Forms.DataGridView](/dotnet/api/System.Windows.Forms.DataGridView) control to display the output of the commands in a Windows Forms application. ## Example -This sample runs the [Get-Process](/powershell/module/Microsoft.PowerShell.Management/Get-Process) and [Sort-Object](/powershell/module/Microsoft.PowerShell.Utility/Sort-Object) cmdlets synchronously in the default runspace provided by Windows PowerShell. The output is displayed in a form using a [System.Windows.Forms.Datagridview](/dotnet/api/System.Windows.Forms.DataGridView) control. +This sample runs the [Get-Process](/powershell/module/Microsoft.PowerShell.Management/Get-Process) and [Sort-Object](/powershell/module/Microsoft.PowerShell.Utility/Sort-Object) cmdlets synchronously in the default runspace provided by Windows PowerShell. The output is displayed in a form using a [System.Windows.Forms.DataGridView](/dotnet/api/System.Windows.Forms.DataGridView) control. ```csharp namespace Microsoft.Samples.PowerShell.Runspaces @@ -58,7 +58,7 @@ namespace Microsoft.Samples.PowerShell.Runspaces // building all of the other data structures needed to run the command. using (PowerShell powershell = PowerShell.Create()) { - powershell.AddCommand("get-process").AddCommand("sort-object").AddArgument("ID"); + powershell.AddCommand("Get-Process").AddCommand("Sort-Object").AddArgument("ID"); if (Runspace.DefaultRunspace == null) { Runspace.DefaultRunspace = powershell.Runspace; diff --git a/reference/docs-conceptual/developer/hosting/runspace03-sample.md b/reference/docs-conceptual/developer/hosting/runspace03-sample.md index 5a9a7221ccfc..5c6587e8aa0a 100644 --- a/reference/docs-conceptual/developer/hosting/runspace03-sample.md +++ b/reference/docs-conceptual/developer/hosting/runspace03-sample.md @@ -6,7 +6,7 @@ title: Runspace03 Sample --- # Runspace03 Sample -This sample shows how to use the [System.Management.Automation.Powershell](/dotnet/api/system.management.automation.powershell) class to run a script synchronously, and how to handle non-terminating errors. The script receives a list of process names and then retrieves those processes. The results of the script, including any non-terminating errors that were generated when running the script, are displayed in a console window. +This sample shows how to use the [System.Management.Automation.PowerShell](/dotnet/api/system.management.automation.powershell) class to run a script synchronously, and how to handle non-terminating errors. The script receives a list of process names and then retrieves those processes. The results of the script, including any non-terminating errors that were generated when running the script, are displayed in a console window. ## Requirements @@ -16,9 +16,9 @@ This sample requires Windows PowerShell 2.0. This sample demonstrates the following. -- Creating a [System.Management.Automation.Powershell](/dotnet/api/system.management.automation.powershell) object to run a script. +- Creating a [System.Management.Automation.PowerShell](/dotnet/api/system.management.automation.powershell) object to run a script. -- Adding a script to the pipeline of the [System.Management.Automation.Powershell](/dotnet/api/system.management.automation.powershell) object. +- Adding a script to the pipeline of the [System.Management.Automation.PowerShell](/dotnet/api/system.management.automation.powershell) object. - Passing input objects to the script from the calling program. @@ -75,7 +75,7 @@ namespace Microsoft.Samples.PowerShell.Runspaces // The script to run to get these processes. Input passed // to the script will be available in the $input variable. - string script = "$input | get-process -name {$_}"; + string script = "$input | Get-Process -Name {$_}"; // Create a PowerShell object. Creating this object takes care of // building all of the other data structures needed to run the script. diff --git a/reference/docs-conceptual/developer/hosting/runspace04-sample.md b/reference/docs-conceptual/developer/hosting/runspace04-sample.md index e4113c4ac112..97537fdbea40 100644 --- a/reference/docs-conceptual/developer/hosting/runspace04-sample.md +++ b/reference/docs-conceptual/developer/hosting/runspace04-sample.md @@ -6,7 +6,7 @@ title: Runspace04 Sample --- # Runspace04 Sample -This sample shows how to use the [System.Management.Automation.Powershell](/dotnet/api/system.management.automation.powershell) class to run commands, and how to catch terminating errors that are thrown when running the commands. Two commands are run, and the last command is passed a parameter argument that is not valid. As a result, no objects are returned and a terminating error is thrown. +This sample shows how to use the [System.Management.Automation.PowerShell](/dotnet/api/system.management.automation.powershell) class to run commands, and how to catch terminating errors that are thrown when running the commands. Two commands are run, and the last command is passed a parameter argument that is not valid. As a result, no objects are returned and a terminating error is thrown. ## Requirements @@ -16,9 +16,9 @@ This sample requires Windows PowerShell 2.0. This sample demonstrates the following. -- Creating a [System.Management.Automation.Powershell](/dotnet/api/system.management.automation.powershell) object. +- Creating a [System.Management.Automation.PowerShell](/dotnet/api/system.management.automation.powershell) object. -- Adding commands to the pipeline of the [System.Management.Automation.Powershell](/dotnet/api/system.management.automation.powershell) object. +- Adding commands to the pipeline of the [System.Management.Automation.PowerShell](/dotnet/api/system.management.automation.powershell) object. - Adding parameter arguments to the pipeline.