{
  "name": "PowerShell",
  "scopeName": "source.powershell",
  "patterns": [
    {
      "name": "comment.block.powershell",
      "begin": "\u003c#",
      "end": "#\u003e",
      "patterns": [
        {
          "include": "#commentEmbeddedDocs"
        }
      ],
      "beginCaptures": {
        "0": {
          "name": "punctuation.start.definition.comment.block.powershell"
        }
      },
      "endCaptures": {
        "0": {
          "name": "punctuation.end.definition.comment.block.powershell"
        }
      }
    },
    {
      "name": "comment.line.number-sign.powershell",
      "begin": "(?\u003c![\\\\-])#",
      "end": "$",
      "patterns": [
        {
          "include": "#commentEmbeddedDocs"
        }
      ]
    },
    {
      "name": "keyword.operator.redirection.powershell",
      "match": "[2-6]\u003e\u00261|\u003e\u003e|\u003e|\u003c\u003c|\u003c|\u003e|\u003e\\||[1-6]\u003e|[1-6]\u003e\u003e"
    },
    {
      "include": "#commands"
    },
    {
      "include": "#variable"
    },
    {
      "include": "#interpolatedStringContent"
    },
    {
      "include": "#function"
    },
    {
      "include": "#attribute"
    },
    {
      "include": "#type"
    },
    {
      "name": "string.quoted.double.powershell",
      "begin": "(?\u003c!(?\u003c!`)\")\"",
      "end": "\"(?!\")",
      "patterns": [
        {
          "include": "#variableNoProperty"
        },
        {
          "include": "#doubleQuotedStringEscapes"
        },
        {
          "include": "#interpolation"
        },
        {
          "name": "keyword.other.powershell",
          "match": "`\\s*$"
        }
      ]
    },
    {
      "include": "#doubleQuotedStringEscapes"
    },
    {
      "name": "string.quoted.single.powershell",
      "begin": "(?\u003c!')'",
      "end": "'(?!')",
      "patterns": [
        {
          "name": "constant.character.escape.powershell",
          "match": "''"
        }
      ]
    },
    {
      "name": "string.quoted.double.heredoc.powershell",
      "begin": "\\@\"(?=$)",
      "end": "^\"@",
      "patterns": [
        {
          "include": "#variableNoProperty"
        },
        {
          "include": "#doubleQuotedStringEscapes"
        },
        {
          "include": "#interpolation"
        }
      ]
    },
    {
      "name": "string.quoted.single.heredoc.powershell",
      "begin": "\\@'(?=$)",
      "end": "^'@",
      "patterns": [
        {
          "name": "constant.character.escape.powershell",
          "match": "''"
        }
      ]
    },
    {
      "include": "#numericConstant"
    },
    {
      "name": "meta.group.array-expression.powershell",
      "begin": "@\\(",
      "end": "\\)",
      "patterns": [
        {
          "include": "$self"
        }
      ],
      "captures": {
        "0": {
          "name": "keyword.other.powershell"
        }
      }
    },
    {
      "name": "meta.group.complex.subexpression.powershell",
      "begin": "\\$\\(",
      "end": "\\)",
      "patterns": [
        {
          "include": "$self"
        }
      ],
      "captures": {
        "0": {
          "name": "keyword.other.powershell"
        }
      }
    },
    {
      "name": "keyword.operator.logical.powershell",
      "match": "(?\u003c!\\w)-([ci]?[lg][te]|eq|ne)"
    },
    {
      "name": "support.function.powershell",
      "match": "(?i:[a-z][a-z0-9]+-?[a-z][a-z0-9]+)(?i:\\.(?i:exe|cmd|bat|ps1))"
    },
    {
      "name": "keyword.control.powershell",
      "match": "(?\u003c!\\w)((?i:begin|break|catch|continue|data|define|do|dynamicparam|else|elseif|end|exit|finally|for|foreach(?!-object)|from|if|in|inlinescript|parallel|param|process|return|switch|throw|trap|try|until|using|var|where(?!=-object)|while)|%|\\?)(?!\\w)"
    },
    {
      "match": "(?\u003c!\\w)((?i:class)|%|\\?)(?:\\s)+((?:\\p{L}|\\d|_|-|)+)\\b",
      "captures": {
        "1": {
          "name": "storage.type.powershell"
        },
        "2": {
          "name": "entity.name.function"
        }
      }
    },
    {
      "name": "keyword.operator.comparison.powershell",
      "match": "(?\u003c!\\w)-(?i:is(?:not)?|as)\\b"
    },
    {
      "name": "keyword.operator.comparison.powershell",
      "match": "(?\u003c!\\w)-(?i:[ic]?(?:eq|ne|[gl][te]|(?:not)?(?:like|match|contains|in)|replace))(?!\\p{L})"
    },
    {
      "name": "keyword.operator.unary.powershell",
      "match": "(?\u003c!\\w)-(?i:join|split)(?!\\p{L})|!"
    },
    {
      "name": "keyword.operator.logical.powershell",
      "match": "(?\u003c!\\w)-(?i:and|or|not|xor)(?!\\p{L})|!"
    },
    {
      "name": "keyword.operator.bitwise.powershell",
      "match": "(?\u003c!\\w)-(?i:band|bor|bnot|bxor)(?!\\p{L})"
    },
    {
      "name": "keyword.operator.string-format.powershell",
      "match": "(?\u003c!\\w)-(?i:f)(?!\\p{L})"
    },
    {
      "name": "keyword.operator.assignment.powershell",
      "match": "[+%*/-]?=|[+/*%-]"
    },
    {
      "name": "keyword.other.statement-separator.powershell",
      "match": "\\|{2}|\u0026{2}|;"
    },
    {
      "name": "keyword.operator.other.powershell",
      "match": "\u0026|(?\u003c!\\w)\\.(?= )|`|,|\\|"
    },
    {
      "name": "keyword.operator.range.powershell",
      "match": "(?\u003c!\\s|^)\\.\\.(?=\\d|\\(|\\$)"
    }
  ],
  "repository": {
    "attribute": {
      "begin": "\\[(\\p{L}|\\.|``\\d+)+(?=\\()",
      "end": "\\]",
      "patterns": [
        {
          "name": "entity.other.attribute-name",
          "begin": "\\(",
          "end": "\\)",
          "patterns": [
            {
              "name": "entity.other.attribute-name.powershell",
              "match": "(\\w+)\\s*=?([^\"']*?|'[^']*?'|\"[^\"]*?\")?(?=,|\\))",
              "captures": {
                "0": {
                  "name": "entity.other.attribute.parameter.powershell"
                },
                "1": {
                  "name": "constant.language.powershell"
                },
                "2": {
                  "name": "variable.other.powershell"
                }
              }
            },
            {
              "include": "#variable"
            }
          ]
        }
      ],
      "beginCaptures": {
        "0": {
          "name": "entity.name.tag"
        },
        "1": {
          "name": "entity.name.tag"
        }
      },
      "endCaptures": {
        "0": {
          "name": "entity.name.tag"
        }
      }
    },
    "commands": {
      "patterns": [
        {
          "name": "support.function.powershell",
          "match": "(?:(\\p{L}|\\d|_|-|\\\\|\\:)*\\\\)?\\b(?i:Add|Approve|Assert|Backup|Block|Checkpoint|Clear|Close|Compare|Complete|Compress|Confirm|Connect|Convert|ConvertFrom|ConvertTo|Copy|Debug|Deny|Disable|Disconnect|Dismount|Edit|Enable|Enter|Exit|Expand|Export|Find|Format|Get|Grant|Group|Hide|Import|Initialize|Install|Invoke|Join|Limit|Lock|Measure|Merge|Mount|Move|New|Open|Optimize|Out|Ping|Pop|Protect|Publish|Push|Read|Receive|Redo|Register|Remove|Rename|Repair|Request|Reset|Resize|Resolve|Restart|Restore|Resume|Revoke|Save|Search|Select|Send|Set|Show|Skip|Split|Start|Step|Stop|Submit|Suspend|Switch|Sync|Test|Trace|Unblock|Undo|Uninstall|Unlock|Unprotect|Unpublish|Unregister|Update|Use|Wait|Watch|Write)\\-.+?(?:\\.(?i:exe|cmd|bat|ps1))?\\b"
        },
        {
          "name": "support.function.powershell",
          "match": "(?\u003c!\\w)(?i:foreach-object)(?!\\w)"
        }
      ]
    },
    "commentEmbeddedDocs": {
      "patterns": [
        {
          "name": "comment.documentation.embedded.powershell",
          "match": "(?i:\\s*(\\.)(SYNOPSIS|DESCRIPTION|EXAMPLE|INPUTS|OUTPUTS|NOTES|LINK|COMPONENT|FUNCTIONALITY))",
          "captures": {
            "1": {
              "name": "constant.string.documentation.powershell"
            },
            "2": {
              "name": "keyword.operator.documentation.powershell"
            }
          }
        },
        {
          "name": "comment.documentation.embedded.powershell",
          "match": "(?i:\\s*(\\.)(PARAMETER|FORWARDHELPTARGETNAME|FORWARDHELPCATEGORY|REMOTEHELPRUNSPACE|EXTERNALHELP)\\s+([a-z0-9-_]+))",
          "captures": {
            "1": {
              "name": "constant.string.documentation.powershell"
            },
            "2": {
              "name": "keyword.operator.documentation.powershell"
            },
            "3": {
              "name": "keyword.operator.documentation.powershell"
            }
          }
        },
        {
          "name": "comment.documentation.embedded.powershell",
          "match": "(?i:requires\\s+-(Version\\s+\\d(.\\d+)?|Assembly\\s+(.*)|Module\\s+(.*)|PsSnapIn\\s+(.*)|ShellId\\s+(.*)))",
          "captures": {
            "1": {
              "name": "constant.string.documentation.powershell"
            },
            "2": {
              "name": "keyword.operator.documentation.powershell"
            },
            "3": {
              "name": "string.quoted.double.heredoc.powershell"
            }
          }
        }
      ]
    },
    "doubleQuotedStringEscapes": {
      "patterns": [
        {
          "name": "constant.character.escape.powershell",
          "match": "`[0abnfrvt\"'$`]"
        },
        {
          "name": "constant.character.escape.powershell",
          "match": "\"\""
        }
      ]
    },
    "function": {
      "begin": "((?i:function|filter|configuration|workflow))\\s+((?:\\p{L}|\\d|_|-|\\.)+)",
      "end": "\\{|\\(",
      "beginCaptures": {
        "0": {
          "name": "meta.function"
        },
        "1": {
          "name": "storage.type"
        },
        "2": {
          "name": "entity.name.function"
        }
      }
    },
    "interpolatedStringContent": {
      "contentName": "interpolated.simple.source.powershell",
      "begin": "\\(",
      "end": "\\)",
      "patterns": [
        {
          "include": "$self"
        },
        {
          "include": "#interpolation"
        },
        {
          "include": "#interpolatedStringContent"
        }
      ],
      "beginCaptures": {
        "0": {
          "name": "keyword.other.powershell"
        }
      },
      "endCaptures": {
        "0": {
          "name": "keyword.other.powershell"
        }
      }
    },
    "interpolation": {
      "contentName": "interpolated.complex.source.powershell",
      "begin": "(\\$)\\(",
      "end": "\\)",
      "patterns": [
        {
          "include": "$self"
        },
        {
          "include": "#interpolation"
        },
        {
          "include": "#interpolatedStringContent"
        }
      ],
      "beginCaptures": {
        "0": {
          "name": "keyword.other.powershell"
        }
      },
      "endCaptures": {
        "0": {
          "name": "keyword.other.powershell"
        }
      }
    },
    "numericConstant": {
      "patterns": [
        {
          "name": "constant.numeric.hexadecimal.powershell",
          "match": "(?\u003c!\\w)(?i:(0x)([a-f0-9]+)((?i:L)?(?i:[kmgtp]b)?))(?!\\w)",
          "captures": {
            "1": {
              "name": "keyword.operator.math.powershell"
            },
            "2": {
              "name": "support.constant.powershell"
            },
            "3": {
              "name": "keyword.other.powershell"
            }
          }
        },
        {
          "name": "constant.numeric.scientific.powershell",
          "match": "(?\u003c!\\w)(?i:(\\d*\\.?\\d+)(?:((?i:E)[+-]?)(\\d+))?((?i:[DL])?)((?i:[kmgtp]b)?))(?!\\w)",
          "captures": {
            "1": {
              "name": "support.constant.powershell"
            },
            "2": {
              "name": "keyword.operator.math.powershell"
            },
            "3": {
              "name": "support.constant.powershell"
            },
            "4": {
              "name": "keyword.other.powershell"
            },
            "5": {
              "name": "keyword.other.powershell"
            }
          }
        }
      ]
    },
    "scriptblock": {
      "name": "meta.scriptblock.powershell",
      "begin": "\\{",
      "end": "\\}",
      "patterns": [
        {
          "include": "$self"
        }
      ]
    },
    "type": {
      "begin": "\\[",
      "end": "\\]",
      "patterns": [
        {
          "name": "entity.other.attribute-name",
          "match": "(\\p{L}|\\.|``\\d+)+?"
        },
        {
          "include": "$self"
        }
      ],
      "beginCaptures": {
        "0": {
          "name": "entity.other.attribute-name"
        }
      },
      "endCaptures": {
        "0": {
          "name": "entity.other.attribute-name"
        }
      }
    },
    "variable": {
      "patterns": [
        {
          "match": "(\\$)(?i:(False|Null|True))\\b",
          "captures": {
            "1": {
              "name": "keyword.other.powershell"
            },
            "2": {
              "name": "constant.language.powershell"
            }
          }
        },
        {
          "match": "(\\$)(?i:(Error|ExecutionContext|Host|Home|PID|PsHome|PsVersionTable|ShellID))((?:\\.(?:\\p{L}|\\d|_)+)*\\b)?\\b",
          "captures": {
            "1": {
              "name": "keyword.other.powershell"
            },
            "2": {
              "name": "support.constant.variable.powershell"
            },
            "3": {
              "name": "entity.name.function.invocation.powershell"
            }
          }
        },
        {
          "match": "(\\$)(?i:(\\$|\\^|\\?|_|Args|ConsoleFileName|Event|EventArgs|EventSubscriber|ForEach|Input|LastExitCode|Matches|MyInvocation|NestedPromptLevel|Profile|PSBoundParameters|PsCmdlet|PsCulture|PSDebugContext|PSItem|PSCommandPath|PSScriptRoot|PsUICulture|Pwd|Sender|SourceArgs|SourceEventArgs|StackTrace|Switch|This))((?:\\.(?:\\p{L}|\\d|_)+)*\\b)?\\b",
          "captures": {
            "1": {
              "name": "keyword.other.powershell"
            },
            "2": {
              "name": "support.constant.automatic.powershell"
            },
            "3": {
              "name": "entity.name.function.invocation.powershell"
            }
          }
        },
        {
          "match": "(\\$)(?i:(ConfirmPreference|DebugPreference|ErrorActionPreference|ErrorView|FormatEnumerationLimit|MaximumAliasCount|MaximumDriveCount|MaximumErrorCount|MaximumFunctionCount|MaximumHistoryCount|MaximumVariableCount|OFS|OutputEncoding|ProgressPreference|PsCulture|PSDebugContext|PSDefaultParameterValues|PSEmailServer|PSItem|PSModuleAutoloadingPreference|PSSenderInfo|PSSessionApplicationName|PSSessionConfigurationName|PSSessionOption|VerbosePreference|WarningPreference|WhatIfPreference))((?:\\.(?:\\p{L}|\\d|_)+)*\\b)?\\b",
          "captures": {
            "1": {
              "name": "keyword.other.powershell"
            },
            "2": {
              "name": "variable.language.powershell"
            },
            "3": {
              "name": "entity.name.function.invocation.powershell"
            }
          }
        },
        {
          "match": "(?i:(\\$)(global|local|private|script|using|workflow):((?:\\p{L}|\\d|_)+))((?:\\.(?:\\p{L}|\\d|_)+)*\\b)?",
          "captures": {
            "1": {
              "name": "keyword.other.powershell"
            },
            "2": {
              "name": "storage.modifier.scope.powershell"
            },
            "3": {
              "name": "variable.other.normal.powershell"
            },
            "4": {
              "name": "entity.name.function.invocation.powershell"
            }
          }
        },
        {
          "match": "(?i:(\\$\\{)(global|local|private|script|using|workflow):([^}]*[^}`])(\\}))((?:\\.(?:\\p{L}|\\d|_)+)*\\b)?",
          "captures": {
            "1": {
              "name": "keyword.other.powershell"
            },
            "2": {
              "name": "storage.modifier.scope.powershell"
            },
            "3": {
              "name": "variable.other.readwrite.powershell"
            },
            "4": {
              "name": "keyword.other.powershell"
            },
            "5": {
              "name": "entity.name.function.invocation.powershell"
            }
          }
        },
        {
          "match": "(?i:(\\$)((?:\\p{L}|\\d|_)+:)?((?:\\p{L}|\\d|_)+))((?:\\.(?:\\p{L}|\\d|_)+)*\\b)?",
          "captures": {
            "1": {
              "name": "keyword.other.powershell"
            },
            "2": {
              "name": "support.variable.drive.powershell"
            },
            "3": {
              "name": "variable.other.readwrite.powershell"
            },
            "4": {
              "name": "entity.name.function.invocation.powershell"
            }
          }
        },
        {
          "match": "(?i:(\\$\\{)((?:\\p{L}|\\d|_)+:)?([^}]*[^}`])(\\}))((?:\\.(?:\\p{L}|\\d|_)+)*\\b)?",
          "captures": {
            "1": {
              "name": "keyword.other.powershell"
            },
            "2": {
              "name": "support.variable.drive.powershell"
            },
            "3": {
              "name": "variable.other.readwrite.powershell"
            },
            "4": {
              "name": "keyword.other.powershell"
            },
            "5": {
              "name": "entity.name.function.invocation.powershell"
            }
          }
        }
      ]
    },
    "variableNoProperty": {
      "patterns": [
        {
          "match": "(\\$)(?i:(False|Null|True))\\b",
          "captures": {
            "1": {
              "name": "keyword.other.powershell"
            },
            "2": {
              "name": "constant.language.powershell"
            }
          }
        },
        {
          "match": "(\\$)(?i:(Error|ExecutionContext|Host|Home|PID|PsHome|PsVersionTable|ShellID))\\b",
          "captures": {
            "1": {
              "name": "keyword.other.powershell"
            },
            "2": {
              "name": "support.constant.variable.powershell"
            },
            "3": {
              "name": "entity.name.function.invocation.powershell"
            }
          }
        },
        {
          "match": "(\\$)(?i:(\\$|\\^|\\?|_|Args|ConsoleFileName|Event|EventArgs|EventSubscriber|ForEach|Input|LastExitCode|Matches|MyInvocation|NestedPromptLevel|Profile|PSBoundParameters|PsCmdlet|PsCulture|PSDebugContext|PSItem|PSCommandPath|PSScriptRoot|PsUICulture|Pwd|Sender|SourceArgs|SourceEventArgs|StackTrace|Switch|This))\\b",
          "captures": {
            "1": {
              "name": "keyword.other.powershell"
            },
            "2": {
              "name": "support.variable.automatic.powershell"
            },
            "3": {
              "name": "entity.name.function.invocation.powershell"
            }
          }
        },
        {
          "match": "(\\$)(?i:(ConfirmPreference|DebugPreference|ErrorActionPreference|ErrorView|FormatEnumerationLimit|MaximumAliasCount|MaximumDriveCount|MaximumErrorCount|MaximumFunctionCount|MaximumHistoryCount|MaximumVariableCount|OFS|OutputEncoding|ProgressPreference|PsCulture|PSDebugContext|PSDefaultParameterValues|PSEmailServer|PSItem|PSModuleAutoloadingPreference|PSSenderInfo|PSSessionApplicationName|PSSessionConfigurationName|PSSessionOption|VerbosePreference|WarningPreference|WhatIfPreference))\\b",
          "captures": {
            "1": {
              "name": "keyword.other.powershell"
            },
            "2": {
              "name": "variable.language.powershell"
            },
            "3": {
              "name": "entity.name.function.invocation.powershell"
            }
          }
        },
        {
          "match": "(?i:(\\$)(global|local|private|script|using|workflow):((?:\\p{L}|\\d|_)+))",
          "captures": {
            "1": {
              "name": "keyword.other.powershell"
            },
            "2": {
              "name": "storage.modifier.scope.powershell"
            },
            "3": {
              "name": "variable.other.normal.powershell"
            },
            "4": {
              "name": "entity.name.function.invocation.powershell"
            }
          }
        },
        {
          "match": "(?i:(\\$\\{)(global|local|private|script|using|workflow):([^}]*[^}`])(\\}))",
          "captures": {
            "1": {
              "name": "keyword.other.powershell"
            },
            "2": {
              "name": "storage.modifier.scope.powershell"
            },
            "3": {
              "name": "variable.other.readwrite.powershell"
            },
            "4": {
              "name": "keyword.other.powershell"
            },
            "5": {
              "name": "entity.name.function.invocation.powershell"
            }
          }
        },
        {
          "match": "(?i:(\\$)((?:\\p{L}|\\d|_)+:)?((?:\\p{L}|\\d|_)+))",
          "captures": {
            "1": {
              "name": "keyword.other.powershell"
            },
            "2": {
              "name": "support.variable.drive.powershell"
            },
            "3": {
              "name": "variable.other.readwrite.powershell"
            },
            "4": {
              "name": "entity.name.function.invocation.powershell"
            }
          }
        },
        {
          "match": "(?i:(\\$\\{)((?:\\p{L}|\\d|_)+:)?([^}]*[^}`])(\\}))",
          "captures": {
            "1": {
              "name": "keyword.other.powershell"
            },
            "2": {
              "name": "support.variable.drive.powershell"
            },
            "3": {
              "name": "variable.other.readwrite.powershell"
            },
            "4": {
              "name": "keyword.other.powershell"
            },
            "5": {
              "name": "entity.name.function.invocation.powershell"
            }
          }
        }
      ]
    }
  }
}