Search Wiki:


TypeName DoNotAccessPipelineParametersOutsideProcessRecord
CheckId PS1003
Error-Level Error
Category Microsoft.PowerShell
Certainty 95%
Cause A cmdlet accesses a parameter that takes pipeline input, but it does so from outside of a ProcessRecord method.
Rule descriptionDuring execution of BeginProcessing and EndProcessing methods, pipeline input is not correctly bound to a cmdlet parameter. A cmdlet must override a ProcessRecord method to handle pipeline input bound to parameters correctly.
How to fix violations Do one of the following: 1) Override a ProcessRecord method, and use this method to handle pipeline input bound to parameters -or- 2) Do not use the ValueFromPipeline or ValueFromPipelineByPropertyName properties of the ParameterAttribute attribute, which bind the parameter to pipeline input.
When to exclude warnings Do not suppress warnings from this rule.
Related rules OverrideProcessRecordIfAcceptingPipelineInput
See also FxCop Rules for Windows PowerShell


    [Cmdlet("Write", "String")]
    public class WriteStringCommand : PSCmdlet
        [Parameter(ValueFromPipeline = true)]
        public string[] InputObject
            get { return this.inputObject; }
            set { this.inputObject = value; }
        private string[] inputObject;
        // The following command does not work correctly:
        //   "aaa", "bbb", "ccc" | Write-String
        // To fix the error in the example, 
        // change the BeginProcessing method 
        // to ProcessRecord.
        protected override void BeginProcessing()
            // this.inputObject should be accessed
            // only within a ProcessRecord method.
            foreach (string s in this.inputObject)

Back to FxCop Rules for Windows PowerShell.
Last edited Mar 25 2010 at 12:07 AM  by JuneB, version 3
Page view tracker