Tuesday, January 17, 2012

Powershell ScriptCop

I am a fan of Perl Critic the perl tool which gies feedback on your Perl scripts to see if they follow standard conventions, when I read about ScriptCop for PowerShell I downloaded it and tested it out. Seems like a great start to have Perl Critic functions for PowerShell.

Downloaded and copied the files here:

C:\Users\FunkyUser\Documents\WindowsPowerShell\Modules\ScriptCop

Folder Tree
C:\Users\FunkyUser\Documents\WindowsPowerShell\Modules>tree
Folder PATH listing
Volume serial number is 803E-1130
C:.
└───ScriptCop
├───en-us
├───Fixers
├───Patrols
└───Rules

I was then able to use Import-Module ScriptCop.
Finally I used Test-Command Scriptname.ps1 and got some feedback on my code.

I was hoping that I would be able to run a fix and get the indenting corrected, however I didn’t find that function in the existing download.

The Scripting Guy had wrote about ScriptCop, also to note I leared about ScriptCop while looking at Powershell notes on Stack OverFlow.
http://stackoverflow.com/

http://blogs.technet.com/b/heyscriptingguy/archive/2011/07/30/use-scriptcop-to-help-write-better-powershell-scripts.aspx