| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
PSScriptAnalyzer is a static code checker for PowerShell modules and scripts. PSScriptAnalyzer checks the quality of PowerShell code by running a set of rules. The rules are based on PowerShell best practices identified by PowerShell Team and the community. It generates DiagnosticResults (errors and warnings) to inform users about potential code defects and suggests possible solutions for improvements.
PSScriptAnalyzer ships with a collection of built-in rules that check various aspects of PowerShell code such as:
Conceptual user documentation has been moved out of the source code repository and into the documentation 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 code repository should only contain documentation for the code base, such as how to build the code or how to contribute to the code.
User documentation that has been migrated:
There is one exception - the documentation for the rules and cmdlets will remain in the docs folder to facilitate build testing and to be archived as part of each release. Only the documentation for the latest release is published on on learn.microsoft.com.
To install PSScriptAnalyzer from the PowerShell Gallery, see Installing PSScriptAnalyzer or simply open PowerShell in a Terminal and run:
Install-Module -Name PSScriptAnalyzerTo install PSScriptAnalyzer from source code:
Obtain the source
Download the latest source code from the release page OR
Clone the repository (needs git)
git clone https://github.com/PowerShell/PSScriptAnalyzerNavigate to the source directory
cd path/to/PSScriptAnalyzerBuilding You can either build using the Visual Studio solution PSScriptAnalyzer.sln or build using PowerShell specifically for your platform as follows:
The default build is for the currently used version of PowerShell
.\build.ps1Windows PowerShell version 5.0
.\build.ps1 -PSVersion 5PowerShell 7
.\build.ps1 -PSVersion 7Rebuild documentation since it gets built automatically only the first time
.\build.ps1 -DocumentationBuild all versions (PowerShell v5 and v7) and documentation
.\build.ps1 -AllImport the module
Import-Module .\out\PSScriptAnalyzer\[version]\PSScriptAnalyzer.psd1To confirm installation: run Get-ScriptAnalyzerRule in the PowerShell console to obtain the built-in rules.
Adding/Removing resource strings
For adding/removing resource strings in the *.resx files, it is recommended to use Visual Studio since it automatically updates the strongly typed *.Designer.cs files. The Visual Studio 2017 Community Edition is free to use but should you not have/want to use Visual Studio then you can either manually adapt the *.Designer.cs files or use the New-StronglyTypedCsFileForResx.ps1 script although the latter is discouraged since it leads to a bad diff of the *.Designer.cs files.
Pester-based ScriptAnalyzer Tests are located in path/to/PSScriptAnalyzer/Tests folder.
./build -TestTo retrieve the results of the run, you can use the tools which are part of the build module (build.psm1)
Import-Module ./build.psm1
Get-TestResultsTo retrieve only the errors, you can use the following:
Import-Module ./build.psm1
Get-TestFailuresThe documentation in this section can be found in Using PSScriptAnalyzer.
There are many ways to contribute:
Import-Module .\Utils\ReleaseMaker.psm1
New-ReleasePlease see our Code of Conduct before participating in this project.
For any security issues, please see our Security Policy.
| Back | FazBrowse Home | New Git URL |