Testing cmdlets with FxCop

Testing cmdlets with FxCop

  • Comments 2

Windows PowerShell wouldn’t be very useful without all the great cmdlets that actually manage specific technologies.  We want to help cmdlet developers to create high-quality cmdlets.  Today we announce availability of FxCop rules that can be used to verify compliance with some of the Cmdlet Design Guidelines as well as to find some of the common bugs.


Use the following procedure to download the required components:

  1. Download Microsoft FxCop 1.36 from the Microsoft Download Center at http://go.microsoft.com/fwlink/?LinkID=185006.
  2. Download Microsoft.PowerShell.CodeAnalysis.dll from the MSDN Code Gallery at http://go.microsoft.com/fwlink/?LinkId=185007. Save the file in any location.

Use the following procedure to configure Microsoft FxCop to run FxCop Rules for Windows PowerShell on your code:

  1. Click Start and then click Microsoft FxCop 1.36.
  2. From the Project menu, select Add Rules, navigate to the Microsoft.PowerShell.CodeAnalysis.dll file, and click Open.
  3. From the Project menu, select Add Targets, navigate to the .dll file that implements your cmdlets, and click Open.
  4. From the Project menu, select Analyze or press F5.

Please refer to the FxCop Rules for Windows PowerShell project on Code Gallery for more details.

List of rules


Lukasz Anforowicz [MSFT]
Windows PowerShell Developer
Microsoft Corporation

Leave a Comment
  • Please add 5 and 3 and type the answer here:
  • Post
  • Great idea! This will certainly help cmdlet authors fall into the pit of success. Almost makes me want to re-write all my advanced functions (which were previously snapins) in C# again. :)

  • There's is a little bug in the doku for the UseCredentialAttributeForPSCredentialParameter rule. Please take a look at the "Cause" row:

    "A cmdlet calls the ShouldContinue method, but it does not have a Force parameter."

    That's clearly not the cause for this rule to kick in.


Page 1 of 1 (2 items)