PowerTip: Finding the Type of an Object

Question: What .NET Framework class is leveraged by the Get-EventLog cmdlet?

Answer: System.Diagnostics.EventLogEntry

Question: How would I find the above information?

Answer: Get-EventLog application | get-member


Comments (6)

  1. jrv says:

    @?? Red Med ORed.

    Locally no issue.  Just be carefully remoely.

  2. K_Schulte says:

    @jrv: You are absolutely right!

    And I really agree that this should be considered!


  3. mredwilson says:

    @Walid Toumi  that is a great suggestion, and a technique I had forgotten about. Thank you for sharing.

  4. mredwilson says:

    @JRV you are absolutely correct, and I suspect that one would only make that "mistake" once … and now maybe not even once with your suggestion! When working locally, if I need to find information about an object, I often use the same code that I am going to use later, and therefore do not modify it to only return a single instance. Then when the information comes pouring in, I press CTRL-C to break up the returning information, so I can "quickly" get the information. Certainly it is better to use one of your solutions, but that does require a lot of extra typing. Depending on what I am doing, I will use GetType as you suggest.

  5. jrv says:

    If we run that solution on a large application log we might end up waiting all day for the output to end.  This happens if we are running over an RDP link.  The control keys so not work as expected.  Ctrl-C does not terminate output.  We could be forced to abort the PowerShell session (Ctlrl-Break).

    Try this as it is cleaner:

    (get-eventlog -Newest 1 -LogName application).GetType()

    (get-process system).GetType()

    (Get-Service browser).GetType()

    (get-wmiobject win32_bios).GetType()

    Design a command that returns only one example and use GetType()

    I use GM when I already have an exemplar and want to inspect it.

    $p=Get-Process w*



    Many ways to do similar things.

  6. Walid Toumi says:

    you can also explore typenames:

    (Get-EventLog -LogName application -Newest 1).pstypenames

Skip to main content