about_Reserved_Words

適用於: Windows PowerShell 2.0, Windows PowerShell 3.0, Windows PowerShell 4.0, Windows PowerShell 5.0

主題

about_Reserved_Words

簡短描述

列出無法做為識別項使用的保留字,因為它們在 Windows PowerShell® 具有特殊意義。

詳細描述

Windows PowerShell 中有某些有特殊意義的字。當這些字在沒有引號的情況下出現時,Windows PowerShell 會嘗試套用其特殊意義,而不是將它們視為字元字串。若要使用這些字在命令或指令碼中做為參數引數,而不叫用其特殊意義,請以引號括住保留字。

以下是 Windows PowerShell 中的保留字:

        Begin              Exit               Process
        Break              Filter             Return
        Catch              Finally            Sequence
        Class              For                Switch
        Continue           ForEach            Throw
        Data               From               Trap
        Define             Function           Try
        Do                 If                 Until
        DynamicParam       In                 Using
        Else               InlineScript       Var
        ElseIf             Parallel           While
        End                Param              Workflow

如需語言陳述式的詳細資訊,包括 Foreach、If、For 和 While,請輸入 "Get-help",再輸入 "about_" 前置詞,然後輸入陳述式的名稱。例如,若要取得 Foreach 陳述式的相關資訊,請輸入:

        Get-Help about_ForEach

如需 Filter 陳述式或 Return 陳述式語法的相關資訊,請輸入:

        Get-Help about_Functions

如需其他保留字的相關資訊,請輸入:

        Get-Help <Reserved_Word>

另請參閱

about_Command_Syntax

about_Escape_Characters

about_Language_Keywords

about_Parsing

about_Quoting_Rules

about_Script_Blocks

about_Special_Characters