Getting an event date in powershell

Posted on 2012-08-15
Last Modified: 2012-08-15
Trying to come up with a way to pull logs from a 2008 R2 server I've pieced together this powershell script from other users examples, but I can't find how how to get the TimeCreated value.  How can I get the event date?

Get-WinEvent -LogName Microsoft-Windows-PrintService/Operational -ComputerName $PrintServer |
     Where-Object{$ -eq 307}|
     $strOutput = $PrintServer+ "," +$($_.Properties["TimeCreated"].Value)+ "," +$($_.Properties[1].Value)+ "," +$($_.Properties[2].Value)+ "," +$($_.Properties[4].Value)+ "," +$($_.Properties[3].Value)+ "," +$($_.Properties[6].Value)+ "," +$($_.Properties[7].Value)
		write-output $strOutput | Out-File $csvfile -append

Open in new window

The ...["TimeCreated"].Value doesn't work, it returns nothing.  The rest of that script gets the values from Param1, Param2, Param3, etc from the <UserData> XML section, but I need to get the date from the <System> section.
Question by:bigbigpig
    LVL 3

    Accepted Solution

    How about using $_.timecreated ?
    LVL 10

    Author Closing Comment

    Perfect - thank you!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Maximize Your Threat Intelligence Reporting

    Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

    Hi all.   The other day I had to change the passwords for a bunch of users on the fly. Because they were so many, I decided to do it in an automated way and I would like to share it with you all.   If you are not doing it directly in a Domain Co…
    "Migrate" an SMTP relay receive connector to a new server using info from an old server.
    The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
    This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    7 Experts available now in Live!

    Get 1:1 Help Now