IT Pro fear no more! Introducing the SPCAF PowerShell CmdLet

Attention IT Pros!

This time we have something for you!

PowerShellWe are happy to announce the availability of the new SPCAF PowerShell CmdLet enabling you to analyze the code quality of your SharePoint solutions (.wsp) and apps (.apps) in your solution deployment scripts, your farm health checks or anywhere else you are using PowerShell to automate SharePoint management tasks including migration and governance solutions like AvePoint’s DocAve, Metalogix Content Matrix or Sharegate’s Sharegate :)

SPCAF PowerShell includes the same five analysis components as the the full client for Code Quality Analysis, Metrics, Dependency Analysis, Inventory and Migration Assessment.

With the PowerShell provided scripts you can download all WSP solutions and apps and check them against over 600 code quality rules. The generated reports show you if the solutions are well developed or contain issues which may harm the performance, supportability and stability of your farm.

Get a free Code Quality Summary Report

If you don’t own a license SPCAF creates a free summary report (HTML) that highlights the found issues and their categories and summarizes the code metrics.

SummaryReport

SPCAF Summary Report

Integrate the Analysis into your Solution Deployment Process

SPSDIf you already use PowerShell to deploy solutions and apps to SharePoint, for example with the help of our free SharePoint Solution Deployer (SPSD) script, then you can easily integrate the SPCAF analysis into your deployment process:

Run the analysis right before the customizations are deployed to SharePoint and stop the deployment if critical issues have been identified. This ensures a better code quality of your deployed solutions and apps and improves stability, performance and security of your SharePoint environment.

How to use SPCAF PowerShell

Using SPCAF PowerShell is very straight forward. After importing the SPCAF.PowerShell.dll module you can invoke an analysis for a single solution or app or for a complete folder.
You can pass your custom ruleset configuration to adjust which rules are checked as well as define the output formats and the report location and name.

Example:

To make your life easier the download already includes two sample scripts to show you how to

1. AnalyzeSolutionsLocally.ps1

 2. LoadAndAnalyzeSolutionsFromSharePoint.ps1

If you like to download additionally apps and sandboxed solutions from your farm for the analysis, then check out my blog on how to extract all customizations from your farm in which you will find the required PowerShell script.

Command Line Parameters

SPCAF PowerShell comes with a range of parameters that allow you to configure the analysis to your needs.

Parameter   Value   Mandatory   Description  
InputFiles String Array Yes List of input files or directory for the analysis. Support formats: .wsp, .app, .dll, .exe, .zip.
LicenseFiles String Array No Optional path to SPCAF license files. If no license file is given only the free feature are activated.
SettingsFile String No Optional name or path to the settings files (.spruleset) which defines the analyzers for the analysis.
Reports String Array No List of report formats which should be generated during the analysis. Possible values: HTML, PDF, DOCX, XML, CSV, DGML.
OutputFile String No Optional path the output file. The reports will be written to the same location as the output file in the various formats.
Verbosity String No Optional level for verbosity to limit the detail level for log messages. Valid values are: quiet, minimal, normal, Default
TempDirectory String No Optional path to the temp folder.
SkipProjectCreation Boolean No Optional Boolean. Default FALSE. If TRUE no project (.spcaf) file is created as output of the analysis.
TimeOut Integer No Optional seconds after the analysis should be cancelled automatically.

Results

Apart from generating the detailled reports, SPCAF PowerShell outputs the number of issues to the console and provides the gathered information to the PowerShell pipe for further processing eg. to cancel the deployment.

Note: The number of issues is also available when running SPCAF PowerShell without a license making it easy to integrate in in every deployment process.

Sample Output:

Try it now!

You can download the SPCAF PowerShell CmdLet from the TechNet Galleries

Download the SPCAF PowerShell CmdLet

Feedback

We would be very happy to hear your feedback about how you are using SPCAF PowerShell, so please tell us your experiences and feature requests either in the comments below or by mailing us to feedback@spcaf.com.

Thank you!