Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Download ScriptAnalyzer from PowerShellGallery

License

NotificationsYou must be signed in to change notification settings

PowerShell/PSScriptAnalyzer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build StatusJoin the chat at https://gitter.im/PowerShell/PSScriptAnalyzer

Table of Contents

Introduction

PSScriptAnalyzer is a static code checker for PowerShell modules and scripts. PSScriptAnalyzerchecks the quality of PowerShell code by running aset of rules. The rules are basedon PowerShell best practices identified by PowerShell Team and the community. It generatesDiagnosticResults (errors and warnings) to inform users about potential code defects and suggestspossible solutions for improvements.

PSScriptAnalyzer ships with a collection of built-in rules that check various aspects ofPowerShell code such as:

  • The presence of uninitialized variables
  • Use ofPSCredential type
  • Use ofInvoke-Expression
  • And many more

Back to ToC

DOCUMENTATION NOTICE

Conceptual user documentation has been moved out of the source code repository and into thedocumentation repository so that it can be published on learn.microsoft.com.

The goal of this migration is to have the user documentation on learn.microsoft.com. The source coderepository should only contain documentation for the code base, such as how to build the code or howto contribute to the code.

User documentation that has been migrated:

There is one exception - the documentation for the rules and cmdlets will remain in thedocsfolder to facilitate build testing and to be archived as part of each release. Only thedocumentation for the latest release is published on on learn.microsoft.com.

Installation

To installPSScriptAnalyzer from the PowerShell Gallery, seeInstalling PSScriptAnalyzer.

To installPSScriptAnalyzer from source code:

Requirements

Steps

  • Obtain the source

    • Download the latest source code from therelease page OR

    • Clone the repository (needs git)

      git clone https://github.com/PowerShell/PSScriptAnalyzer
  • Navigate to the source directory

    cd path/to/PSScriptAnalyzer
  • Building You can either build using theVisual Studio solutionPSScriptAnalyzer.sln or buildusingPowerShell specifically for your platform as follows:

    • The default build is for the currently used version of PowerShell

      .\build.ps1
    • Windows PowerShell version 5.0

      .\build.ps1-PSVersion5
    • PowerShell 7

      .\build.ps1-PSVersion7
  • Rebuild documentation since it gets built automatically only the first time

    .\build.ps1-Documentation
  • Build all versions (PowerShell v5 and v7) and documentation

    .\build.ps1-All
  • Import the module

    Import-Module .\out\PSScriptAnalyzer\[version]\PSScriptAnalyzer.psd1

To confirm installation: runGet-ScriptAnalyzerRule in the PowerShell console to obtain thebuilt-in rules.

  • Adding/Removing resource strings

    For adding/removing resource strings in the*.resx files, it is recommended to useVisual Studio since it automatically updates the strongly typed*.Designer.cs files. TheVisual Studio 2017 Community Edition is free to use but should you not have/want to useVisual Studio then you can either manually adapt the*.Designer.cs files or use theNew-StronglyTypedCsFileForResx.ps1 script although the latter is discouraged since it leads to abad diff of the*.Designer.cs files.

Tests

Pester-based ScriptAnalyzer Tests are located inpath/to/PSScriptAnalyzer/Tests folder.

  • EnsurePester of at least version 5.3 is installed
  • In the root folder of your local repository, run:
./build-Test

To retrieve the results of the run, you can use the tools which are part of the build module (build.psm1)

Import-Module ./build.psm1Get-TestResults

To retrieve only the errors, you can use the following:

Import-Module ./build.psm1Get-TestFailures

Back to ToC

Using PSScriptAnalyzer

The documentation in this section can be found inUsing PSScriptAnalyzer.

Contributions are welcome

There are many ways to contribute:

  1. Open a new bug report, feature request or just ask a question by opening anew issue.
  2. Participate in the discussions ofissues,pull requests and test fixes or newfeatures.
  3. Submit your own fixes or features as a pull request but please discuss it beforehand in an issue.
  4. Submit test cases.

Back to ToC

Creating a Release

  • Update changelog (changelog.md) with the new version number and change set. When updating thechangelog please follow the same pattern as that of previous change sets (otherwise this may breakthe next step).
  • Import the ReleaseMaker module and executeNew-Release cmdlet to perform the following actions.
    • Update module manifest (engine/PSScriptAnalyzer.psd1) with the new version number and change set
    • Update the version number inEngine/Engine.csproj andRules/Rules.csproj
    • Create a release build inout/
Import-Module .\Utils\ReleaseMaker.psm1New-Release
  • Sign the binaries and PowerShell files in the release build and publish the module toPowerShell Gallery.
  • Draft a new release on github and tagmaster with the new version number.

Back to ToC

Code of Conduct

Please see ourCode of Conduct before participating in this project.

Back to ToC

Security Policy

For any security issues, please see ourSecurity Policy.

Back to ToC


[8]ページ先頭

©2009-2025 Movatter.jp