Member_2_6492660_1
asked on
Exchange 2010 New-MailboxExportRequest Script Help
Exchange Server 2010 SP1 Enterprise 64 bit
Windows 2008 R2 64 bit
Every week I export the journal mailbox to a pst file.
I had this for Exchange 2007 journal.ps1 which is called from a cmd file journal.cmd
@echo off
del c:\util\journal.txt
cd\util
C:\Windows\System32\Window sPowerShel l\v1.0\Pow erShell.ex e -PSConsoleFile "D:\Program Files\Microsoft\Exchange Server\V14\Bin\ExShell.psc 1" -Command "./journal.ps1"
Exit
The 2007 journal.ps1
$today = Get-Date -Format "MMddyyyy"
$Folder = "O:\email\journal\journal- $today"
Export-Mailbox –Identity journal -PSTFolderPath "$folder.pst" -confirm:$false -verbose -baditemlimit 99999 -StartDate $((Get-date).AddDays(-7)) –EndDate $(Get-date) -deletecontent >>journal.txt
Now on 2010 you have New-MailboxExportRequest
$today = Get-Date -Format "MMddyyyy"
$Folder = "O:\email\journal\journal- $today"
New-MailboxExportRequest –Mailbox journal -FilePath "$folder.pst" -confirm:$false -verbose -baditemlimit 99999 -StartDate $((Get-date).AddDays(-7)) –EndDate $(Get-date) -deletecontent >>journal.txt
The above fails on -Startdate
Trying to export the inbox by the previous week this runs every Monday at 5:00 PM
The output file journal-01052015.pst is the file format I would like to preserve.
Thanks
Windows 2008 R2 64 bit
Every week I export the journal mailbox to a pst file.
I had this for Exchange 2007 journal.ps1 which is called from a cmd file journal.cmd
@echo off
del c:\util\journal.txt
cd\util
C:\Windows\System32\Window
Exit
The 2007 journal.ps1
$today = Get-Date -Format "MMddyyyy"
$Folder = "O:\email\journal\journal-
Export-Mailbox –Identity journal -PSTFolderPath "$folder.pst" -confirm:$false -verbose -baditemlimit 99999 -StartDate $((Get-date).AddDays(-7)) –EndDate $(Get-date) -deletecontent >>journal.txt
Now on 2010 you have New-MailboxExportRequest
$today = Get-Date -Format "MMddyyyy"
$Folder = "O:\email\journal\journal-
New-MailboxExportRequest –Mailbox journal -FilePath "$folder.pst" -confirm:$false -verbose -baditemlimit 99999 -StartDate $((Get-date).AddDays(-7)) –EndDate $(Get-date) -deletecontent >>journal.txt
The above fails on -Startdate
Trying to export the inbox by the previous week this runs every Monday at 5:00 PM
The output file journal-01052015.pst is the file format I would like to preserve.
Thanks
ASKER
Brendan
I tried that thanks see my results
$today = Get-Date -Format "MMddyyyy"
$Folder = "O:\email\journal\journal- $today"
[System.Reflection.Assembl y]::LoadWi thPartialN ame("Syste m.Threadin g")
[System.Reflection.Assembl y]::LoadWi thPartialN ame("Syste m.Globaliz ation")
[System.Threading.Thread]: :CurrentTh read.Curre ntCulture = [System.Globalization.Cult ureInfo]:: CreateSpec ificCultur e("en-us")
$start = (get-date).adddays(-7)
$end = (get-date).adddays
$filter = "(Received -gt '"+$start+"') -and (Received -lt '"+$end+"')"
New-MailboxExportRequest –Mailbox journal -FilePath "$folder.pst" -ContentFilter $filter -confirm:$false -verbose -baditemlimit 1 >>journal.txt
Output
C:\Util>journal
C:\Util>rem @echo off
C:\Util>del c:\util\journal.txt
C:\Util>cd\util
C:\Util>C:\Windows\System3 2\WindowsP owerShell\ v1.0\Power Shell.exe -PSConsoleFile
"D:\Program Files\Microsoft\Exchange Server\V14\Bin\ExShell.psc 1" -Command "./j
ournal.ps1"
VERBOSE: [00:33:02.536 GMT] New-MailboxExportRequest : Initializing Active
Directory server settings for the local Windows PowerShell session.
VERBOSE: [00:33:03.170 GMT] New-MailboxExportRequest : Active Directory session
settings for 'New-MailboxExportRequest' are: View Entire Forest: 'True',
VERBOSE: [00:33:03.708 GMT] New-MailboxExportRequest : Runspace context:
Executing user: our.network.tgcsnet.com/Us ers/Admini strator, Executing user
organization: , Current organization: , RBAC-enabled: Disabled.
VERBOSE: [00:33:03.715 GMT] New-MailboxExportRequest : Beginning processing
New-MailboxExportRequest
VERBOSE: [00:33:04.074 GMT] New-MailboxExportRequest : Instantiating handler
with index 0 for cmdlet extension agent "Admin Audit Log Agent".
WARNING: When an item can't be read from the source location or can't be
written to the target location, it will be considered corrupted. By specifying
a non-zero BadItemLimit, you're requesting that Exchange not copy such items to
the target location. When the request is complete, such corrupted items won't
be available at the target. When the source is deleted, these items will be
completely lost.
VERBOSE: [00:33:04.507 GMT] New-MailboxExportRequest : Admin Audit Log: Entered
Handler:OnComplete.
The provided ContentFilter value is invalid. ContentFilter is invalid. The valu
e "System.DateTime AddDays(double value)" could not be converted to type System
.DateTime. --> The value "System.DateTime AddDays(double value)" could not be c
onverted to type System.DateTime.
At C:\Util\journal.ps1:10 char:1
+ <<<< New-MailboxExportRequest -Mailbox journal -FilePath "$folder.pst" -Cont
entFilter $filter -confirm:$false -verbose -baditemlimit 1 >>journal.txt
+ CategoryInfo : InvalidArgument: ((Received -gt '...double value
)'):String) [], ContentFilterInvalidPerman entExcepti on
+ FullyQualifiedErrorId : 1FD9192E
C:\Util>Pause
Press any key to continue . . .
Terminate batch job (Y/N)? y
C:\Util>
Thoughts
I tried that thanks see my results
$today = Get-Date -Format "MMddyyyy"
$Folder = "O:\email\journal\journal-
[System.Reflection.Assembl
[System.Reflection.Assembl
[System.Threading.Thread]:
$start = (get-date).adddays(-7)
$end = (get-date).adddays
$filter = "(Received -gt '"+$start+"') -and (Received -lt '"+$end+"')"
New-MailboxExportRequest –Mailbox journal -FilePath "$folder.pst" -ContentFilter $filter -confirm:$false -verbose -baditemlimit 1 >>journal.txt
Output
C:\Util>journal
C:\Util>rem @echo off
C:\Util>del c:\util\journal.txt
C:\Util>cd\util
C:\Util>C:\Windows\System3
"D:\Program Files\Microsoft\Exchange Server\V14\Bin\ExShell.psc
ournal.ps1"
VERBOSE: [00:33:02.536 GMT] New-MailboxExportRequest : Initializing Active
Directory server settings for the local Windows PowerShell session.
VERBOSE: [00:33:03.170 GMT] New-MailboxExportRequest : Active Directory session
settings for 'New-MailboxExportRequest'
VERBOSE: [00:33:03.708 GMT] New-MailboxExportRequest : Runspace context:
Executing user: our.network.tgcsnet.com/Us
organization: , Current organization: , RBAC-enabled: Disabled.
VERBOSE: [00:33:03.715 GMT] New-MailboxExportRequest : Beginning processing
New-MailboxExportRequest
VERBOSE: [00:33:04.074 GMT] New-MailboxExportRequest : Instantiating handler
with index 0 for cmdlet extension agent "Admin Audit Log Agent".
WARNING: When an item can't be read from the source location or can't be
written to the target location, it will be considered corrupted. By specifying
a non-zero BadItemLimit, you're requesting that Exchange not copy such items to
the target location. When the request is complete, such corrupted items won't
be available at the target. When the source is deleted, these items will be
completely lost.
VERBOSE: [00:33:04.507 GMT] New-MailboxExportRequest : Admin Audit Log: Entered
Handler:OnComplete.
The provided ContentFilter value is invalid. ContentFilter is invalid. The valu
e "System.DateTime AddDays(double value)" could not be converted to type System
.DateTime. --> The value "System.DateTime AddDays(double value)" could not be c
onverted to type System.DateTime.
At C:\Util\journal.ps1:10 char:1
+ <<<< New-MailboxExportRequest -Mailbox journal -FilePath "$folder.pst" -Cont
entFilter $filter -confirm:$false -verbose -baditemlimit 1 >>journal.txt
+ CategoryInfo : InvalidArgument: ((Received -gt '...double value
)'):String) [], ContentFilterInvalidPerman
+ FullyQualifiedErrorId : 1FD9192E
C:\Util>Pause
Press any key to continue . . .
Terminate batch job (Y/N)? y
C:\Util>
Thoughts
$today = Get-Date -Format "MMddyyyy"
$Folder = "O:\email\journal\journal-$today"
[System.Reflection.Assembly]::LoadWithPartialName("System.Threading")
[System.Reflection.Assembly]::LoadWithPartialName("System.Globalization")
[System.Threading.Thread]::CurrentThread.CurrentCulture = [System.Globalization.CultureInfo]::CreateSpecificCulture("en-us")
$start = (get-date).adddays(-7)
$end = (get-date)
$filter = "(Received -gt '"+$start+"') -and (Received -lt '"+$end+"')"
New-MailboxExportRequest –Mailbox journal -FilePath "$folder.pst" -ContentFilter "$filter" -confirm:$false -verbose -baditemlimit 1 >>journal.txt
please try
ASKER
Branden
Great
I had to also modify the $folder value was invalid as it was had to use this instead \\10.2.8.20\volume_1\email \journal\j ournal-$to day
In 2007 the export had this parameter " -deletecontent " this is not an 2010 option
It cleared the inbox after the export ran.
How can I do that now?
would search-mailbox work?
I just want to cleared the inbox of all records after the export
Thoughts
Great
I had to also modify the $folder value was invalid as it was had to use this instead \\10.2.8.20\volume_1\email
In 2007 the export had this parameter " -deletecontent " this is not an 2010 option
It cleared the inbox after the export ran.
How can I do that now?
would search-mailbox work?
I just want to cleared the inbox of all records after the export
Thoughts
have a look at the "removing messages" section
http://blogs.technet.com/b/exchange/archive/2010/10/27/3411398.aspx
http://blogs.technet.com/b/exchange/archive/2010/10/27/3411398.aspx
ASKER
Branden
Search-Mailbox -Identity "journal" -SearchQuery ????????????? -DeleteContent
Where can I find the options for -Searchquery?
If I want to delete the entire inbox?
Search-Mailbox -Identity "journal" -SearchQuery ????????????? -DeleteContent
Where can I find the options for -Searchquery?
If I want to delete the entire inbox?
example:
Search-Mailbox -Identity usermailbox -SearchQuery {sent:02/01/2013..02/30/20 13} -LogOnly -LogLevel full
it uses Advanced Query Syntax
https://msdn.microsoft.com/en-us/library/aa965711%28v=vs.85%29.aspx
to delete everything
just leave the -searchquery blank
Search-Mailbox -Identity usermailbox -SearchQuery {sent:02/01/2013..02/30/20
it uses Advanced Query Syntax
https://msdn.microsoft.com/en-us/library/aa965711%28v=vs.85%29.aspx
to delete everything
just leave the -searchquery blank
ASKER
Brandan
Thanks
Search-Mailbox -Identity usermailbox -SearchQuery {sent:'$start'..'$end'} -LogOnly -LogLevel full
will that work?
Thanks
Search-Mailbox -Identity usermailbox -SearchQuery {sent:'$start'..'$end'} -LogOnly -LogLevel full
will that work?
maybe, you might have to use
$start = (get-date).adddays(-7).Date
$end = (get-date).Date
ASKER
Brandan
Sounds good will test that out
One other thing
If I add that to my journal.ps1 script as the last line will it try to delete the items before the nw-mailboxexportrequest completes?
So this is the complete script
$today = Get-Date -Format "MMddyyyy"
$Folder = "\\10.2.8.20\volume_1\emai l\journal\ journal-$t oday"
[System.Reflection.Assembl y]::LoadWi thPartialN ame("Syste m.Threadin g")
[System.Reflection.Assembl y]::LoadWi thPartialN ame("Syste m.Globaliz ation")
[System.Threading.Thread]: :CurrentTh read.Curre ntCulture = [System.Globalization.Cult ureInfo]:: CreateSpec ificCultur e("en-us")
$start = (get-date).adddays(-7) .Date
$end = (get-date) .Date
$filter = "(Received -gt '"+$start+"') -and (Received -lt '"+$end+"')"
New-MailboxExportRequest –Mailbox journal -FilePath "$folder.pst" -ContentFilter "$filter" -confirm:$false -verbose -baditemlimit 1 >>journal.txt
Search-Mailbox -Identity usermailbox -SearchQuery {sent:'$Start'..'$End'} -LogOnly -LogLevel full -DeleteContent
Sounds good will test that out
One other thing
If I add that to my journal.ps1 script as the last line will it try to delete the items before the nw-mailboxexportrequest completes?
So this is the complete script
$today = Get-Date -Format "MMddyyyy"
$Folder = "\\10.2.8.20\volume_1\emai
[System.Reflection.Assembl
[System.Reflection.Assembl
[System.Threading.Thread]:
$start = (get-date).adddays(-7) .Date
$end = (get-date) .Date
$filter = "(Received -gt '"+$start+"') -and (Received -lt '"+$end+"')"
New-MailboxExportRequest –Mailbox journal -FilePath "$folder.pst" -ContentFilter "$filter" -confirm:$false -verbose -baditemlimit 1 >>journal.txt
Search-Mailbox -Identity usermailbox -SearchQuery {sent:'$Start'..'$End'} -LogOnly -LogLevel full -DeleteContent
ASKER
Branden
Testing this
example:
Search-Mailbox -Identity usermailbox -SearchQuery {sent:02/01/2013..02/30/20 13} -LogOnly -LogLevel full
I get Specify Folder prompt what am I missing?
Testing this
example:
Search-Mailbox -Identity usermailbox -SearchQuery {sent:02/01/2013..02/30/20
I get Specify Folder prompt what am I missing?
Looks like you need to be using something similar to the following:
$today = Get-Date -Format "MMddyyyy"
$Folder = "\\10.2.8.20\volume_1\emai l\journal\ journal-$t oday"
[System.Reflection.Assembl y]::LoadWi thPartialN ame("Syste m.Threadin g")
[System.Reflection.Assembl y]::LoadWi thPartialN ame("Syste m.Globaliz ation")
[System.Threading.Thread]: :CurrentTh read.Curre ntCulture = [System.Globalization.Cult ureInfo]:: CreateSpec ificCultur e("en-us")
$start = (get-date).adddays(-7) .Date
$end = (get-date) .Date
$filter = "(Received -gt '"+$start+"') -and (Received -lt '"+$end+"')"
New-MailboxExportRequest –Mailbox journal -FilePath "$folder.pst" -ContentFilter {(Received -lt $end) -and (Received -gt $start)} -confirm:$false -verbose -baditemlimit 1 >>journal.txt
Don't quote me - I'm no scripting guru!!
Alan
$today = Get-Date -Format "MMddyyyy"
$Folder = "\\10.2.8.20\volume_1\emai
[System.Reflection.Assembl
[System.Reflection.Assembl
[System.Threading.Thread]:
$start = (get-date).adddays(-7) .Date
$end = (get-date) .Date
$filter = "(Received -gt '"+$start+"') -and (Received -lt '"+$end+"')"
New-MailboxExportRequest –Mailbox journal -FilePath "$folder.pst" -ContentFilter {(Received -lt $end) -and (Received -gt $start)} -confirm:$false -verbose -baditemlimit 1 >>journal.txt
Don't quote me - I'm no scripting guru!!
Alan
ASKER
Alan
Thanks neither am I just dabble a little
I have that part working on exchange 2007 you had export-mailbox that had a -deletecontent
Which was removed in 2010
Now you need
Search-Mailbox -Identity usermailbox -SearchQuery {sent:02/01/2013..02/30/20 13} -LogOnly -LogLevel full -deletecontent
But my test was not to delete just running this
Search-Mailbox -Identity usermailbox -SearchQuery {sent:02/01/2013..02/30/20 13} -LogOnly -LogLevel full
That is when it prompts me for a folder name
Thanks neither am I just dabble a little
I have that part working on exchange 2007 you had export-mailbox that had a -deletecontent
Which was removed in 2010
Now you need
Search-Mailbox -Identity usermailbox -SearchQuery {sent:02/01/2013..02/30/20
But my test was not to delete just running this
Search-Mailbox -Identity usermailbox -SearchQuery {sent:02/01/2013..02/30/20
That is when it prompts me for a folder name
Extract from (https://technet.microsoft.com/en-us/library/dd298173.aspx):
"Use the Search-Mailbox cmdlet to search a mailbox and copy the results to a specified target mailbox"
Therefore you will need the -TargetMailbox "Mailboxname" switch to search and copy the search results to a mailbox.
"Use the Search-Mailbox cmdlet to search a mailbox and copy the results to a specified target mailbox"
Therefore you will need the -TargetMailbox "Mailboxname" switch to search and copy the search results to a mailbox.
ASKER
Alan
I saw that tech note
I was trying to use Example three (3)
Search-Mailbox -Identity "April Stewart" -SearchQuery 'Subject:"Your bank statement"' -DeleteContent
Just trying to change the -Searchquery around
I saw that tech note
I was trying to use Example three (3)
Search-Mailbox -Identity "April Stewart" -SearchQuery 'Subject:"Your bank statement"' -DeleteContent
Just trying to change the -Searchquery around
Do you have the relevant permissions setup on the account you are using to run the command as per the following link:
Relevant Section:
"Delete mailbox content (using the Search-Mailbox cmdlet with the DeleteContent switch)"
https://technet.microsoft.com/en-us/library/dd638205.aspx
Relevant Section:
"Delete mailbox content (using the Search-Mailbox cmdlet with the DeleteContent switch)"
https://technet.microsoft.com/en-us/library/dd638205.aspx
ASKER
Alan
I ran this the other day
PS] C:\Windows\system32>new-ma nagementro leassignme nt -role "mailbox import export" -user administrator
Name Role RoleAssigneeName RoleAssigneeType AssignmentMethod EffectiveUserNam
e
---- ---- ---------------- ---------------- ---------------- ----------------
Mailbox Import Export-Admin... Mailbox Import... Administrator User Direct
I am running this script from the administrator account on the exchange server (domain admin)
I ran this the other day
PS] C:\Windows\system32>new-ma
Name Role RoleAssigneeName RoleAssigneeType AssignmentMethod EffectiveUserNam
e
---- ---- ---------------- ---------------- ---------------- ----------------
Mailbox Import Export-Admin... Mailbox Import... Administrator User Direct
I am running this script from the administrator account on the exchange server (domain admin)
What about the discovery management role too?
ASKER
Alan add it the same way?
new-managementroleassignme nt -role "Discovery Management" -user administrator
new-managementroleassignme
ASKER
Alan
I think I got it
[PS] C:\Windows\system32>get-ro legroupmem ber "Discovery Management"
[PS] C:\Windows\system32>add-ro legroupmem ber "Discovery Management" -Member Administrator
[PS] C:\Windows\system32>get-ro legroupmem ber "Discovery Management"
Name RecipientType
---- -------------
Administrator UserMailbox
[PS] C:\Windows\system32>
Going to test the search-mailbox cmdlet now
I think I got it
[PS] C:\Windows\system32>get-ro
[PS] C:\Windows\system32>add-ro
[PS] C:\Windows\system32>get-ro
Name RecipientType
---- -------------
Administrator UserMailbox
[PS] C:\Windows\system32>
Going to test the search-mailbox cmdlet now
ASKER
Guys
I have the command almost working
This is it
PS] C:\Windows\system32>search -mailbox -identity 'exchange journal' -searchquery "Received:> $('09/29/2014') and Received:< $('09/30/2014')" -deletecontent >c:\temp\delete09.txt
Confirm
Deleting content from mailboxes exchange journal
[Y] Yes [A] Yes to All [N] No [L] No to All [?] Help (default is "Y"): a
Search Failed on mailbox 'our\Exchange Journal\16b6e8c3-75ed-4fb2 -8380-4d3e 86e84016'. If the search query used short words with wildcard(s) such as pat*, it can result in a large number of words or phrases because all permutations of word
s starting with "pat" are searched. Make search queries as specific as possible when using wildcards.
+ CategoryInfo : ReadError: (0:Int32) [Search-Mailbox], SearchMailboxException
+ FullyQualifiedErrorId : 7113682B,Microsoft.Exchang e.Manageme nt.Tasks.S earchMailb ox
ran this
test-exchangesearch journal | fl
it gave me many results so it found it.
Any thoughts?
Thanks
I have the command almost working
This is it
PS] C:\Windows\system32>search
Confirm
Deleting content from mailboxes exchange journal
[Y] Yes [A] Yes to All [N] No [L] No to All [?] Help (default is "Y"): a
Search Failed on mailbox 'our\Exchange Journal\16b6e8c3-75ed-4fb2
s starting with "pat" are searched. Make search queries as specific as possible when using wildcards.
+ CategoryInfo : ReadError: (0:Int32) [Search-Mailbox], SearchMailboxException
+ FullyQualifiedErrorId : 7113682B,Microsoft.Exchang
ran this
test-exchangesearch journal | fl
it gave me many results so it found it.
Any thoughts?
Thanks
is the service "Microsoft Search (Exchange)" and "Microsoft Exchange Search Indexer" running in services?
ASKER
Hi Brandan
Yes both services are running
Microsoft Search (Exchange) is set to manual
Microsoft Exchange Search Indexer is set to automatic
Again both are started
I was looking at this before
https://social.technet.microsoft.com/Forums/exchange/en-US/3ca4f5c6-ca45-454d-9edf-788654a1c718/exchange-2010-sp1-searchmailbox-deletecontent-switch-seems-to-kill-the-query-if-the-logonly
Thoughts
Yes both services are running
Microsoft Search (Exchange) is set to manual
Microsoft Exchange Search Indexer is set to automatic
Again both are started
I was looking at this before
https://social.technet.microsoft.com/Forums/exchange/en-US/3ca4f5c6-ca45-454d-9edf-788654a1c718/exchange-2010-sp1-searchmailbox-deletecontent-switch-seems-to-kill-the-query-if-the-logonly
Thoughts
This any better?
search-mailbox -identity 'exchange journal' -searchquery "Received:09/29/2014..09/3 0/2014" -deletecontent >c:\temp\delete09.txt
search-mailbox -identity 'exchange journal' -searchquery "Received:09/29/2014..09/3
ASKER
All
That worked great.
Results
search-mailbox -identity 'exchange journal' -searchquery "Received:09/29/2014..09/3 0/2014" -deletecontent >c:\temp\delete09.txt
[PS] C:\Windows\system32>search -mailbox -identity 'exchange journal' -searchquery "Received:01/12/2015..01/1 7/2015" -de
letecontent >c:\temp\delete17.txt
Confirm
Deleting content from mailboxes exchange journal
[Y] Yes [A] Yes to All [N] No [L] No to All [?] Help (default is "Y"): y
[PS] C:\Windows\system32>
How do I auto respond to this prompt
That worked great.
Results
search-mailbox -identity 'exchange journal' -searchquery "Received:09/29/2014..09/3
[PS] C:\Windows\system32>search
letecontent >c:\temp\delete17.txt
Confirm
Deleting content from mailboxes exchange journal
[Y] Yes [A] Yes to All [N] No [L] No to All [?] Help (default is "Y"): y
[PS] C:\Windows\system32>
How do I auto respond to this prompt
Try this:
search-mailbox -identity 'exchange journal' -searchquery "Received:01/12/2015..01/1 7/2015" -deletecontent >c:\temp\delete17.txt -confirm:$false
search-mailbox -identity 'exchange journal' -searchquery "Received:01/12/2015..01/1
ASKER
Alan
Sorry tried that still prompting me
Thoughts
Sorry tried that still prompting me
Thoughts
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Alan
That did it all my research could not find -force
Now I need to build the script so I can automate this
That did it all my research could not find -force
Now I need to build the script so I can automate this
Gleamed that little gem from here:
https://technet.microsoft.com/en-us/library/dd298173(v=exchg.141).aspx
Parameters section.
https://technet.microsoft.com/en-us/library/dd298173(v=exchg.141).aspx
Parameters section.
ASKER
All
Here is what I did so far
today = Get-Date -Format "MMddyyyy"
$Folder = "\\10.2.8.20\volume_1\emai l\journal\ journal-$t oday"
[System.Reflection.Assembl y]::LoadWi thPartialN ame("Syste m.Threadin g")
[System.Reflection.Assembl y]::LoadWi thPartialN ame("Syste m.Globaliz ation")
[System.Threading.Thread]: :CurrentTh read.Curre ntCulture = [System.Globalization.Cult ureInfo]:: CreateSpec ificCultur e("en-us")
add-pssnapin Microsoft.*
$start = (get-date).adddays(-7)
$end = (get-date)
$filter = "(Received -gt '"+$start+"') -and (Received -lt '"+$end+"')"
New-MailboxExportRequest –Mailbox journal -FilePath "$folder.pst" -ContentFilter "$filter" -confirm:$false -verbose -baditemlimit 1 >>c:\util\journal.txt
Get-MailboxExportRequest | where {$_.status -eq "Completed"} >>c:\util\journal.txt
search-mailbox -identity 'exchange journal' -searchquery "Received:'"+$start+"'..'" +$end+"'" -deletecontent >>c:\util\journal.txt -force
My concern is about the -searchquery "Received:'"+$start+"'..'" +$end+"'"
How does it look
Here is what I did so far
today = Get-Date -Format "MMddyyyy"
$Folder = "\\10.2.8.20\volume_1\emai
[System.Reflection.Assembl
[System.Reflection.Assembl
[System.Threading.Thread]:
add-pssnapin Microsoft.*
$start = (get-date).adddays(-7)
$end = (get-date)
$filter = "(Received -gt '"+$start+"') -and (Received -lt '"+$end+"')"
New-MailboxExportRequest –Mailbox journal -FilePath "$folder.pst" -ContentFilter "$filter" -confirm:$false -verbose -baditemlimit 1 >>c:\util\journal.txt
Get-MailboxExportRequest | where {$_.status -eq "Completed"} >>c:\util\journal.txt
search-mailbox -identity 'exchange journal' -searchquery "Received:'"+$start+"'..'"
My concern is about the -searchquery "Received:'"+$start+"'..'"
How does it look
ASKER
Alan
Thanks for your help
I am opening another question about this
I post it on here when I create it
Thanks for your help
I am opening another question about this
I post it on here when I create it
though you can user the ContentFilter parameter (Send and Received)
https://technet.microsoft.com/en-us/library/ff601762(v=exchg.141).aspx