Expand Minimize

How to: Run SPCAF via PowerShell

SPCAF is now available from PowerShell. Depending on your licence the output will give you a report either editing and using the supplied example script, or creating your own to suit your needs.

SPCAF.PowerShell.dllSPCAF Self Contained PowerShell Module
AnalyzeSolutionsLocally.ps1Sample PowerShell script which analyzes a given set of WSPs locally with SPCAF (without SharePoint installed)
LoadAndAnalyzeSolutionsFromSharePoint.ps1Sample PowerShell script which downloads all full trust solutions form the local SharePoint farm and analyzes them with SPCAF

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 SERVER 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

InputFilesString ArrayYesList of input files or directory for the analysis. Support formats: .wsp, .app, .dll, .exe, .zip.
LicenseFilesString ArrayNoOptional path to SPCAF license files. If no license file is given only the free feature are activated.
SettingsFileStringNoOptional name or path to the settings files (.spruleset) which defines the analyzers for the analysis.
ReportsString ArrayNoList of report formats which should be generated during the analysis. Possible values: HTML, PDF, DOCX, XML, CSV, DGML.
OutputFileStringNoOptional path the output file. The reports will be written to the same location as the output file in the various formats.
VerbosityStringNoOptional level for verbosity to limit the detail level for log messages. Valid values are: quiet, minimal, normal, Default
TempDirectoryStringNoOptional path to the temp folder.
SkipProjectCreationBooleanNoOptional Boolean. Default FALSE. If TRUE no project (.spcaf) file is created as output of the analysis.
TimeOutIntegerNoOptional seconds after the analysis should be cancelled automatically.

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
Disclaimer: The views and opinions expressed in this documentation and in SPCAF do not necessarily reflect the opinions and recommendations of Microsoft or any member of Microsoft. SPCAF and RENCORE are registered trademarks of RENCORE AB. All other trademarks, service marks, collective marks, copyrights, registered names, and marks used or cited by this documentation are the property of their respective owners.