[Exchange 2010 SP1] Script New-MailboxExportRequest with ContentFilter parameters

Status
Not open for further replies.
A

Arlequinlover

Hello

I have a problem to process a New-MailboxExportRequest using a variable with ContentFilter parameter.

When i execute the following command, it is working fine:

New-MailboxExportRequest -mailbox user1.test -contentfilter {Received -gt '01/01/2010'} -filepath \\UNC\Share\user1.test.pst

The request is created, and the PST file contain only the mail since the 01/01/2010.

But when, i use these two following line in a script. It export all :

$startdate='01/01/2010'

New-MailboxExportRequest -mailbox user1.test -contentfilter {Received -gt $startdate} -filepath \\UNC\Share\user1.test.pst

The request is created. but the PSTFile contain the full mailbox.

It is the same when i use this var

$date=get-date

$startdate=$date.addmonths(-6)

New-MailboxExportRequest -mailbox user1.test -contentfilter {Received -gt $startdate} -filepath \\UNC\Share\user1.test.pst

Could someone help me this behaviour, please.
 
M

Michel de Rooij

Received expects something of DateTime type, '01/01/2010' is a string. Try
$startdate= [datetime]::parseExact(" 01/01/2010" ,'d/M/yyyy',$null)

Michel de Rooij,
MCITP Ent.Msg 2007+2010| MCTS W2008, Ex2007+2010 Conf, OCS2007 Conf | MCSE+Msg2k3 | MCSE+Inet2k3 | Prince2 Fnd | ITIL
I blog on http://eightwone.wordpress.com/ and tweet on http://twitter.com/mderooij
 
A

Arlequinlover

$date=get-date

$startdate=$date.addmonths(-6)

Here, $startdate is datetime format but doesn't work.
 
X

xeonium

I have another problem with New-MailboxExportRequest.

When i ran the following Cmdlt, the export works correctly:
New-MailboxExportRequest -Mailbox usermailbox -ContentFilter {Received -gt " 12/10/2010" } -filepath \\UNC\share\usermailbox.pst

The exported PST file contain all mails since 12th October 2010 - so i see in my Outlook.

But when i try this one:
New-MailboxExportRequest -Mailbox usermailbox -ContentFilter {Received -gt " 13/10/2010" } -filepath \\UNC\share\usermailbox.pst

following error occurs:

Der bereitgestellte ContentFilter-Wert ist ungültig. ContentFilter ist ungültig. Der Wert '13/10/2010' konnte nicht in den Typ System.DateTime konvertiert werden. --> Der Wert '13/10/2010' konnte nicht in den Typ System.DateTime konvertiert werden.
+ CategoryInfo : InvalidArgument: (Received -gt " 13/10/2010" :String) [], ContentFilterInvalidPermanentExc
eption
+ FullyQualifiedErrorId : D31211FE

I think it depends on the german language of the system and the datetime format on it. Because no 13th month exists.

If i try to switch the days to the months like " 10/13/2010" the PST(256kb) contains nothing.
 
A

Arlequinlover

I have another problem with New-MailboxExportRequest.

When i ran the following Cmdlt, the export works correctly:
New-MailboxExportRequest -Mailbox usermailbox -ContentFilter {Received -gt " 12/10/2010" } -filepath \\UNC\share\usermailbox.pst

The exported PST file contain all mails since 12th October 2010 - so i see in my Outlook.

But when i try this one:
New-MailboxExportRequest -Mailbox usermailbox -ContentFilter {Received -gt " 13/10/2010" } -filepath \\UNC\share\usermailbox.pst

following error occurs:

Der bereitgestellte ContentFilter-Wert ist ungültig. ContentFilter ist ungültig. Der Wert '13/10/2010' konnte nicht in den Typ System.DateTime konvertiert werden. --> Der Wert '13/10/2010' konnte nicht in den Typ System.DateTime konvertiert werden.
+ CategoryInfo : InvalidArgument: (Received -gt " 13/10/2010" :String) [], ContentFilterInvalidPermanentExc
eption
+ FullyQualifiedErrorId : D31211FE

I think it depends on the german language of the system and the datetime format on it. Because no 13th month exists.

If i try to switch the days to the months like " 10/13/2010" the PST(256kb) contains nothing.
date must be : month/day/year

not day/month/year

You may not have mail greater than 13 October 2010.
 
X

xeonium

date must be : month/day/year

not day/month/year

You may not have mail greater than 13 October 2010.
i agree with you

but in german language the correct format is dd.MM.yyyy

the parameter ContentFilter works fine between 01st and 12th of a day. after that the export won't work.
 
V

Veichtlbauer

as you said correctly, the formatting difference is MM/dd/yyyy vs. dd.MM.yyy - so why do you specify your date as '13/10/2010'? give it a shot with '13.10.2010'...
 
Status
Not open for further replies.
Top