How to: Run SPCAF via PowerShell

This article explains how to install and run SPCAF via PowerShell.

SPCAF is now available via PowerShell. Depending on your license the output will give you a full or trial report, either edit and use the supplied example script or create your own to suit your needs.

SPCAF_PoShRun_Table1_634x201

Install SPCAF for PowerShell

In order to run SPCAF in PowerShell, you will need to go to our downloads page. Select "Farm" below the SPCAF section and then click on the "SPCAF Farm: PowerShell CmdLet.

This will download Rencore.SPCAF.FarmProtection.PowerShell.zip. Open the .zip and extract the contents to folder destination of your choice.

Run analysis from PowerShell

The SPCAF PowerShell Module can be run on any machine with support for .NET 4.0 and at least PowerShell v2.0. The supplied script also requires a SharePoint Farm to be deployed locally, however, it is easily modifiable to work remotely.

Run free analysis without SPCAF license

If you have no SPCAF license, SPCAF creates at least a summary report (format HTML) of the analysis which highlights the main issues and shows the code metrics in charts.

Run analysis with SPCAF license

If you have a valid SPCAF Quality Gate/SPCAF Farm Protection license copy the .lic file to the folder with the PowerShell cmdlet (SPCAF.PowerShell.dll) or provide the path the .lic file in the cmdlet argument "LicenseFiles".

Command Line Parameters

SPCAF_PoShRun_Table2_640x797

Code sample

 Import-Module "x:\spcaf\SPCAF.PowerShell.dll"

 $params = @{

    InputFiles = @("x:\spcaf")

    OutputFile = "x:\spcaf\SPCAF-Report.html"

    Reports = @("HTML")

    LicenseFiles = @("x:\spcaf\pro.lic")

    Timeout = 0 #Infinite timeout

    LogFile = "x:\spcaf\SPCAF.log"

 };

 Invoke-SPCAFCodeAnalysis @params

Tags

Pre-Production | PowerShell | PoSh | Install | Run | Use | Analyse | Analyze | TN_U | BQ_U