[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Getting an event date in powershell

Posted on 2012-08-15
2
Medium Priority
?
1,061 Views
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{$_.id -eq 307}|
     ForEach-Object{
     $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.
0
Comment
Question by:bigbigpig
2 Comments
 
LVL 3

Accepted Solution

by:
Akulsh earned 2000 total points
ID: 38298252
How about using $_.timecreated ?
0
 
LVL 10

Author Closing Comment

by:bigbigpig
ID: 38298261
Perfect - thank you!
0

Featured Post

Simplify Active Directory Administration

Administration of Active Directory does not have to be hard.  Too often what should be a simple task is made more difficult than it needs to be.The solution?  Hyena from SystemTools Software.  With ease-of-use as well as powerful importing and bulk updating capabilities.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are times when we need to generate a report on the inbox rules, where users have set up forwarding externally in their mailbox. In this article, I will be sharing a script I wrote to generate the report in CSV format.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn how to dynamically set the form action using jQuery.
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.
Suggested Courses
Course of the Month19 days, 15 hours left to enroll

873 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