DSC-konfigurációk súgóinak összeállításaWriting help for DSC configurations

A következőkre vonatkozik: Windows PowerShell 5,0Applies To: Windows PowerShell 5.0

A DSC-konfigurációkhoz Megjegyzés-alapú súgót használhat.You can use comment-based help in DSC configurations. A felhasználók a konfiguráció meghívásával -? vagy a Get-Help parancsmag használatával érhetik el a segítséget.Users can access the help by calling the Configuration with -?, or by using the Get-Help cmdlet. A Megjegyzés-alapú súgót közvetlenül a kulcsszó fölé helyezheti Configuration .Place your Comment-based help directly above the Configuration keyword. A paramétert közvetlenül a paraméter deklarációja felett, vagy az alábbi példában látható módon is elhelyezheti a Megjegyzés-blokkban.You can place parameter help in-line with your comment block, directly above the parameter declaration, or both as in the example below.

További információ a PowerShell megjegyzésekre épülő súgóról: about_Comment_Based_Help.For more information about PowerShell comment-based help, see about_Comment_Based_Help.

Megjegyzés

A PowerShell-fejlesztési környezetek, például a VS Code és az ISE, tartalmaz olyan kódrészleteket is, amelyek lehetővé teszik a hozzászólások blokkolására szolgáló sablonok automatikus beszúrását.PowerShell development environments, like VS Code and the ISE, also have snippets to allow you to automatically insert comment block templates.

Az alábbi példa egy olyan parancsfájlt mutat be, amely tartalmazza a konfigurációs és Megjegyzés-alapú súgóját.The following example shows a script that contains a configuration and comment-based help for it. Ez a példa egy paramétereket tartalmazó konfigurációt mutat be.This example shows a Configuration with parameters. Ha többet szeretne megtudni a konfigurációk paramétereinek használatáról, tekintse meg a paraméterek hozzáadása a konfigurációhozcímű témakört.To learn more about using parameters in your Configurations, see Add Parameters to your Configurations.

<#
.SYNOPSIS
A brief description of the function or script. This keyword can be used only once for each configuration.


.DESCRIPTION
A detailed description of the function or script. This keyword can be used only once for each
configuration.

.PARAMETER ComputerName
The description of a parameter. Add a .PARAMETER keyword for each parameter in the function or
script syntax.

Type the parameter name on the same line as the .PARAMETER keyword. Type the parameter description
on the lines following the .PARAMETER keyword. Windows PowerShell interprets all text between the
.PARAMETER line and the next keyword or the end of the comment block as part of the parameter
description. The description can include paragraph breaks.

The Parameter keywords can appear in any order in the comment block, but the function or script
syntax determines the order in which the parameters (and their descriptions) appear in help topic.
To change the order, change the syntax.

.EXAMPLE
HelpSample -ComputerName localhost

A sample command that uses the function or script, optionally followed by sample output and a
description. Repeat this keyword for each example. PowerShell automatically prefaces the first line
with a PowerShell prompt. Additional lines are treated as output and description. The example can
contain spaces, newlines and PowerShell code.

If you have multiple examples, there is no need to number them. PowerShell will number the examples in help text.

.EXAMPLE
HelpSample -FilePath "C:\output.txt"

This example will be labeled "EXAMPLE 2" when help is displayed to the user.
#>
configuration HelpSample1
{
    param
    (
        [string]$ComputerName = 'localhost',
        # Provide a PARAMETER section for each parameter that your script or function accepts.
        [string]$FilePath = 'C:\Destination.txt'
    )

    Node $ComputerName
    {
        File HelloWorld
        {
            Contents="Hello World"
            DestinationPath = $FilePath
        }
    }
}

Konfigurációs Súgó megtekintéseViewing configuration help

Egy konfiguráció súgójának megtekintéséhez használja a Get-Help parancsmagot a függvény nevével, vagy írja be a függvény nevét, majd a nevet -? .To view the help for a configuration, use the Get-Help cmdlet with the name of the function, or type the name of the function followed by -?. A következő az előző konfiguráció kimenetét adja át: Get-Help .The following is the output of the previous Configuration passed to Get-Help.

Get-Help HelpSample1 -Detailed
NAME
    HelpSample1

SYNOPSIS
    A brief description of the function or script. This keyword can be used only once for each configuration.


SYNTAX
    HelpSample1 [[-InstanceName] <String>] [[-DependsOn] <String[]>] [[-PsDscRunAsCredential] <PSCredential>]
      [[-OutputPath] <String>] [[-ConfigurationData] <Hashtable>] [[-ComputerName] <String>] [[-FilePath] <String>]
      [<CommonParameters>]


DESCRIPTION
    A detailed description of the function or script. This keyword can be used only once for each configuration.


PARAMETERS
    -InstanceName <String>

    -DependsOn <String[]>

    -PsDscRunAsCredential <PSCredential>

    -OutputPath <String>

    -ConfigurationData <Hashtable>

    -ComputerName <String>
        The description of a parameter. Add a .PARAMETER keyword for each parameter in the function
        or script syntax.

        Type the parameter name on the same line as the .PARAMETER keyword. Type the parameter
        description on the lines following the .PARAMETER keyword. Windows PowerShell interprets all
        text between the .PARAMETER line and the next keyword or the end of the comment block as
        part of the parameter description. The description can include paragraph breaks.

        The Parameter keywords can appear in any order in the comment block, but the function or
        script syntax determines the order in which the parameters (and their descriptions) appear
        in help topic. To change the order, change the syntax.

    -FilePath <String>
        Provide a PARAMETER section for each parameter that your script or function accepts.

    <CommonParameters>
        This cmdlet supports the common parameters: Verbose, Debug,
        ErrorAction, ErrorVariable, WarningAction, WarningVariable,
        OutBuffer, PipelineVariable, and OutVariable. For more information, see
        about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).

    -------------------------- EXAMPLE 1 --------------------------

    PS C:\>HelpSample -ComputerName localhost

    A sample command that uses the function or script, optionally followed by sample output and a
    description. Repeat this keyword for each example. PowerShell automatically prefaces the first
    line with a PowerShell prompt. Additional lines are treated as output and description. The
    example can contain spaces, newlines and PowerShell code.

    If you have multiple examples, there is no need to number them. PowerShell will number the
    examples in help text.


    -------------------------- EXAMPLE 2 --------------------------

    PS C:\>HelpSample -FilePath "C:\output.txt"

    This example will be labeled "EXAMPLE 2" when help is displayed to the user.


REMARKS
    To see the examples, type: "get-help HelpSample1 -examples".
    For more information, type: "get-help HelpSample1 -detailed".
    For technical information, type: "get-help HelpSample1 -full".

Megjegyzés

A PowerShell használatával automatikusan létrejönnek a szintaxis mezői és a paraméterek attribútumai.Syntax fields and parameter attributes are automatically generated for you by PowerShell.

Lásd még:See Also