@@ -43,7 +43,9 @@ public class InvokeScriptAnalyzerCommand : PSCmdlet, IOutputWriter
4343 /// </summary>
4444 [ Parameter ( Position = 0 ,
4545 ParameterSetName = "File" ,
46- Mandatory = true ) ]
46+ Mandatory = true ,
47+ ValueFromPipeline = true ,
48+ ValueFromPipelineByPropertyName = true ) ]
4749 [ ValidateNotNull ]
4850 [ Alias ( "PSPath" ) ]
4951 public string Path
@@ -58,7 +60,9 @@ public string Path
5860 /// </summary>
5961 [ Parameter ( Position = 0 ,
6062 ParameterSetName = "ScriptDefinition" ,
61- Mandatory = true ) ]
63+ Mandatory = true ,
64+ ValueFromPipeline = true ,
65+ ValueFromPipelineByPropertyName = true ) ]
6266 [ ValidateNotNull ]
6367 public string ScriptDefinition
6468 {
@@ -74,12 +78,12 @@ public string ScriptDefinition
7478 [ ValidateNotNull ]
7579 [ SuppressMessage ( "Microsoft.Performance" , "CA1819:PropertiesShouldNotReturnArrays" ) ]
7680 [ Alias ( "CustomizedRulePath" ) ]
77- public string CustomRulePath
81+ public string [ ] CustomRulePath
7882 {
7983 get { return customRulePath ; }
8084 set { customRulePath = value ; }
8185 }
82- private string customRulePath ;
86+ private string [ ] customRulePath ;
8387
8488 /// <summary>
8589 /// RecurseCustomRulePath: Find rules within subfolders under the path
@@ -93,6 +97,18 @@ public SwitchParameter RecurseCustomRulePath
9397 }
9498 private bool recurseCustomRulePath ;
9599
100+ /// <summary>
101+ /// IncludeDefaultRules: Invoke default rules along with Custom rules
102+ /// </summary>
103+ [ Parameter ( Mandatory = false ) ]
104+ [ SuppressMessage ( "Microsoft.Performance" , "CA1819:PropertiesShouldNotReturnArrays" ) ]
105+ public SwitchParameter IncludeDefaultRules
106+ {
107+ get { return includeDefaultRules ; }
108+ set { includeDefaultRules = value ; }
109+ }
110+ private bool includeDefaultRules ;
111+
96112 /// <summary>
97113 /// ExcludeRule: Array of names of rules to be disabled.
98114 /// </summary>
@@ -157,17 +173,20 @@ public SwitchParameter SuppressedOnly
157173 private bool suppressedOnly ;
158174
159175 /// <summary>
160- /// Returns path to the file that contains user profile for ScriptAnalyzer
176+ /// Returns path to the file that contains user profile or hash table for ScriptAnalyzer
161177 /// </summary>
162178 [ Alias ( "Profile" ) ]
163179 [ Parameter ( Mandatory = false ) ]
164180 [ ValidateNotNull ]
165- public string Configuration
181+ public object Settings
166182 {
167- get { return configuration ; }
168- set { configuration = value ; }
183+ get { return settings ; }
184+ set { settings = value ; }
169185 }
170- private string configuration ;
186+
187+ private object settings ;
188+
189+ private bool stopProcessing ;
171190
172191 #endregion Parameters
173192
@@ -181,21 +200,33 @@ protected override void BeginProcessing()
181200 string [ ] rulePaths = Helper . ProcessCustomRulePaths ( customRulePath ,
182201 this . SessionState , recurseCustomRulePath ) ;
183202
203+ if ( ! ScriptAnalyzer . Instance . ParseProfile ( this . settings , this . SessionState . Path , this ) )
204+ {
205+ stopProcessing = true ;
206+ return ;
207+ }
208+
184209 ScriptAnalyzer . Instance . Initialize (
185210 this ,
186211 rulePaths ,
187212 this . includeRule ,
188213 this . excludeRule ,
189214 this . severity ,
190- this . suppressedOnly ,
191- this . configuration ) ;
215+ null == rulePaths ? true : this . includeDefaultRules ,
216+ this . suppressedOnly ) ;
192217 }
193218
194219 /// <summary>
195220 /// Analyzes the given script/directory.
196221 /// </summary>
197222 protected override void ProcessRecord ( )
198223 {
224+ if ( stopProcessing )
225+ {
226+ stopProcessing = false ;
227+ return ;
228+ }
229+
199230 if ( String . Equals ( this . ParameterSetName , "File" , StringComparison . OrdinalIgnoreCase ) )
200231 {
201232 // throws Item Not Found Exception
@@ -211,6 +242,18 @@ protected override void ProcessRecord()
211242 }
212243 }
213244
245+ protected override void EndProcessing ( )
246+ {
247+ ScriptAnalyzer . Instance . CleanUp ( ) ;
248+ base . EndProcessing ( ) ;
249+ }
250+
251+ protected override void StopProcessing ( )
252+ {
253+ ScriptAnalyzer . Instance . CleanUp ( ) ;
254+ base . StopProcessing ( ) ;
255+ }
256+
214257 #endregion
215258
216259 #region Methods
0 commit comments