Skip to content

POWERSHELL

Linters

Linter Additional
powershell
POWERSHELL_POWERSHELL
GitHub stars autofix
powershell_formatter
POWERSHELL_POWERSHELL_FORMATTER
GitHub stars formatter

Linted files

  • File extensions:
    • .ps1
    • .psm1
    • .psd1
    • .ps1xml
    • .pssc
    • .psrc
    • .cdxml

Configuration in MegaLinter

Variable Description Default value
POWERSHELL_FILTER_REGEX_INCLUDE Custom regex including filter
POWERSHELL_FILTER_REGEX_EXCLUDE Custom regex excluding filter

Behind the scenes

Installation

  • Dockerfile commands :
ARG PWSH_VERSION='latest'
ARG PWSH_DIRECTORY='/opt/microsoft/powershell'
RUN mkdir -p ${PWSH_DIRECTORY} \
    && curl --retry 5 --retry-delay 5 -s \
       -H "Accept: application/vnd.github+json" \
       -H "Authorization: Bearer $(cat /run/secrets/GITHUB_TOKEN)" \
       https://api.github.com/repos/powershell/powershell/releases/${PWSH_VERSION} \
        | grep browser_download_url \
        | grep linux-alpine-x64 \
        | cut -d '"' -f 4 \
        | xargs -n 1 wget -O - \
        | tar -xzC ${PWSH_DIRECTORY} \
    && ln -sf ${PWSH_DIRECTORY}/pwsh /usr/bin/pwsh \
    && chmod +x /usr/bin/pwsh