Question

Is there a way that I can have a class that extends cmdlet write to the powershell console with out writing it to the pipeline?

I'm writing a cmdlet which will write a lot of objects to the pipeline (which people will then pipe into another cmdlet like Export-CSV). The problem is if I start writing info to the console that will get picked up as well.

e.g object 1 object 2 "I am a info message that has been logged to powershell via this.WriteObjct object 3

if I try and pipe the cmdlet into another cmdlet I'll get object 1,2, the info message and 3. I need it so it just pipes object 1,2 and 3.

Can anyone point me in the right direction?

Était-ce utile?

La solution

You should use WriteDebug method or WriteVerbose. You could read more on MSDN in: Adding User Messages to Your Cmdlet

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top