Quantcast
Channel: PowerShell.org » All Posts
Viewing all articles
Browse latest Browse all 13067

Reply To: Event log script help.

$
0
0

First, you set the variable $Date to "24 hours before now" :

$Date = [DateTime]::Now.AddHours(-24)

Then, you set the same variable $Date to another value which means "right now"

$Date = get-date -format 'MMMM-yyyy'

Get-Date means get a DateTime object for right now :

PS C:\> Get-Date
 
08 July 2014 12:36:05

The "-format 'MMMM-yyyy" at the end is just formatting the object representing "right now"
So, when you run :

Get-EventLog -computername $Computername "Application" -After $Date

You are asking for the events which occurred after "right now" , that's why you get nothing.

So, you need to remove the line :

$Date = get-date -format 'MMMM-yyyy'

Viewing all articles
Browse latest Browse all 13067

Trending Articles