# The Problem [Parameter(Mandatory=$True,ValueFromPipelineByPropertyName=$True)] [Management.Automation.ErrorRecord] ,
# The Item with the Problem [Parameter(Mandatory=$True,ValueFromPipelineByPropertyName=$True)] [ValidateScript({ if ( -isnot [Management.Automation.CommandInfo] -and -isnot [Management.Automation.PSModuleInfo] ) { throw 'Must be a CommandInfo or a PSModuleInfo' } return $True })] [PSObject] ,
[Switch] ) If you'll notice, three of these parameters map to the three pieces of information you get when you run Test-Command. The fourth parameter, -NonInteractive, is passed down from Repair-Command. If -NotInteractive is passed, your fixer should not interact with the user in any way. If is it not, a fixer is free to interact with a user. This allows you to write a fixer to get information you could not possibly know automatically (like getting a description of what the command does) If the fixer doesn't know what to do with the problem, it should ignore it. Fixers should identify errors by an ErrorID, which is a property on . In this way, multiple specific errors from a rule can be handled by the same fixer. Where as Rules simply need to report errors, fixers need to provide a little more information. Since Fixers need to provide this information in a consistent way, they use 2 private functions to do the trick: CouldNotFixProblem and TriedToFixProblem There are three different outcomes from a fixer: | The problem could not be identified | Do Nothing | | The problem cannot be fixed | return CouldNotFixProblem | | The fixer tried to fix the problem | return TriedToFixProblem |