Link to home
Create AccountLog in
Avatar of Mandy_
Mandy_

asked on

Powershell MailTracking search fix time (-4) hours

Get-MessageTrackingLog -ResultSize Unlimited -Start (03/05/2013 14:00:00).AddHours(-4) | Where-Object {$_.recipients -like *@gmx*}

Open in new window


This code above not working as i like searching for a fix time minus  x_hours
Also there's sth wrong with the wildcard behind
Avatar of Rajkumar Duraisamy
Rajkumar Duraisamy
Flag of India image

Try this

Define the date prior to running the shell command as below

$now = [DateTime] "03/05/2013 14:00:00"
$Date =$Now.Adhours(-4)

Get-MessageTrackingLog -Start $date .........
{$_.recipients -like '*@gmx*'}
Avatar of Mandy_
Mandy_

ASKER

$now = [DateTime] "03/05/2013 14:00:00"
$Date =$Now.Adhours(-4)

no working............

Method invocation failed because [System.DateTime] doesn't contain a method named 'Adhours'.
Rajkumar mean:

$now = [DateTime] "03/05/2013 14:00:00"
$Date =$Now.Addhours(-4)
ASKER CERTIFIED SOLUTION
Avatar of Raheman M. Abdul
Raheman M. Abdul
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer