We help IT Professionals succeed at work.
Get Started

Getting an event date in powershell

1,079 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.
Comment
Watch Question
Commented:
This problem has been solved!
Unlock 1 Answer and 2 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE