Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - Tracing Cmdlets and providers

Reply
 
Old 04-12-2007   #1 (permalink)
John Vottero


 
 

Tracing Cmdlets and providers

Is there a way to hook into the Set-TraceSource/Trace-Command infrastructure
so that our Cmdlets and Providers can output trace information?


My System SpecsSystem Spec
Old 04-13-2007   #2 (permalink)
klumsy@xtra.co.nz


 
 

Re: Tracing Cmdlets and providers

On Apr 12, 3:36 pm, "John Vottero" <JVott...@mvpsi.com> wrote:
> Is there a way to hook into the Set-TraceSource/Trace-Command infrastructure
> so that our Cmdlets and Providers can output trace information?


PStracesource , is a public class on system.management.automation , as
is as is PStracesourceoptions enum so i don't see why not.

and it uses the standard dotnet tracing techniques..
i.e with this attribute
[TraceSource("Mycommands", "Sometext")]

....

static PSTraceSource tracer = PSTraceSource.GetTracer("Mycommands",
"Sometext");

and using this pattern

using (IDisposable disposable = tracer.TraceMethod())
{
}

If you get anywhere with this, we'd love an example, i haven't
bothered messing very much with it as of yet.

-Karl



My System SpecsSystem Spec
Old 04-13-2007   #3 (permalink)
John Vottero


 
 

Re: Tracing Cmdlets and providers

<klumsy@xtra.co.nz> wrote in message
news:1176441861.301009.45690@w1g2000hsg.googlegroups.com...
> On Apr 12, 3:36 pm, "John Vottero" <JVott...@mvpsi.com> wrote:
>> Is there a way to hook into the Set-TraceSource/Trace-Command
>> infrastructure
>> so that our Cmdlets and Providers can output trace information?

>
> PStracesource , is a public class on system.management.automation , as
> is as is PStracesourceoptions enum so i don't see why not.


PSTraceSource is public but, the constructors and all of the GetTracer
methods are internal. I can't figure out why some of it is public but, it
appears, not enough to be useful.

>
> and it uses the standard dotnet tracing techniques..
> i.e with this attribute
> [TraceSource("Mycommands", "Sometext")]
>


I expected the base class of PSTraceSurce to be TraceSource but, it isn't.

> ...
>
> static PSTraceSource tracer = PSTraceSource.GetTracer("Mycommands",
> "Sometext");
>
> and using this pattern
>
> using (IDisposable disposable = tracer.TraceMethod())
> {
> }


That's what I would like to do but, GetTracer and TraceMethod are both
internal.

>
> If you get anywhere with this, we'd love an example, i haven't
> bothered messing very much with it as of yet.
>


At this point, I just want to be able to spit out text when the user does a
Trace-Command that invokes one of my Cmdlets or Providers.

My System SpecsSystem Spec
Old 04-13-2007   #4 (permalink)
klumsy@xtra.co.nz


 
 

Re: Tracing Cmdlets and providers

hmm, well you can maybe build your own wrapper class and use
reflection to get the internal methods. very hacky though

My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
System.net tracing PowerShell
Book: Professional Windows PowerShell Programming: Snapins, Cmdlets,Hosts and Providers (Paperback) by Wrox PowerShell
Writing generic cmdlets that work across different (navigation) providers PowerShell
tracing Vista General
Installing PowerShell Cmdlets, providers etc. PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46