Jump to content

Recommended Posts

Posted

Hi,

 

I am setting up an exchange server. I have configured journaling, a copy of each email sent in the system goes to this mailbox. They just get dumped into the inbox.

 

Does anyone know anything or have a system i can do to help tidy these up and manage these messages please?

 

Thanks

Posted

At my last school we would make a new jounaling mailbox at the start of the year and dismount the old one and store it away from the server on a USB drive kept in a safe.

Keeps each year seperate and off of the live server but allows them to be revisited as required.

Posted

Hello Chaps / chapets

Here is my power shell script

 

$dtoday = get-date -format "dd-MM-yyyy"

New-Item Y:\$dtoday -type directory -Force

export-Mailbox -Identity [email protected] -PSTFolderPath y:\$dtoday\$dtoday.pst -DeleteContent -confirm:$false

 

All it does is create a folder with todays date then exports the journal mailbox into that folder with a created pst with the same date.

Normally export-mailbox to pst leaves the items in place (strange when the command is export)

So the –deletecontent –confirm:$false does the deletion

Save the script as .ps1 and run it from a scheduled task. You can run the script as many times a day as you need, it will only create one folder and pst per day.

The machine you schedule the task on will need the exchange powershell snapin added.

Hope this helps

Cheers

  • Thanks 1
  • 1 month later...
Posted

Hello FN_GM

Sorry not been on for a few days again.

I am an exchange admin so i had to give myself full permissions on the journal mailbox first

 

add-mailboxpermissions -identity [email protected] -user exchangeadmin -accessrights fullaccess

 

This should do the trick

 

Thanks

  • 3 weeks later...
Posted (edited)
I have finally got around to doing this. Do you have any thoughts on this error please?

 

You don't have the Exchange cmdlets loaded. Either run the script from the exchange management shell, or run a remote powershell session to the Exchange server.

Edited by ascott2
forgot quote
Posted
You don't have the Exchange cmdlets loaded. Either run the script from the exchange management shell, or run a remote powershell session to the Exchange server.

 

I do have them loaded, i have also tried within the Exchange Management Shell. Please see the attached.

 

Thanks

exch.PNG

Posted
export-Mailbox has a -DeleteContent parameter which I think, deletes all the content after the export. It has been a while since I ran this, so double check before running.
  • 3 weeks later...
Posted

I am trying to build this script in 2010 SP2, so have managed to adjust the command to use the new New-MailboxExportRequest but they have deprecated the -deletecontent command and moved it seemingly to the Search-Mailbox command. Which is all well and good for single operations.

 

How do I mix this up into a script, as I assume if i call the first command and then the second, it wont wait for the export and just delete it all!

 

Any help appreciated, I just want to export our journal mailbox out to pst once a month, and then clear down the mailbox. I thought about doing one command one day and then the other the next, but I'm always going to have some tween mails that happen between each command.

 

This is doing my head in!

 

Thanks

 

James

Posted
I am trying to build this script in 2010 SP2, so have managed to adjust the command to use the new New-MailboxExportRequest but they have deprecated the -deletecontent command and moved it seemingly to the Search-Mailbox command. Which is all well and good for single operations.

 

How do I mix this up into a script, as I assume if i call the first command and then the second, it wont wait for the export and just delete it all!

 

Any help appreciated, I just want to export our journal mailbox out to pst once a month, and then clear down the mailbox. I thought about doing one command one day and then the other the next, but I'm always going to have some tween mails that happen between each command.

 

This is doing my head in!

 

Thanks

 

James

@CAWJames Im sure we can help, please can you post the code for the script. If you dont mind i might "borrow" it :)

Posted

After some long hours running around the more 'codier' parts of the net, I have a solution:

 

 

$dtoday = get-date -format "dd-MM-yyyy"

New-Item \\srv-id-009\MonitorArchive$\$dtoday -type directory -Force

New-MailboxExportRequest -Mailbox Email_journal_user -FilePath \\srv-id-009\MonitorArchive$\$dtoday\$dtoday.pst

 

while ((Get-MailboxExportRequest -Mailbox Email_journal_user | Where {$_.Status -eq "Queued" -or $_.Status -eq "InProgress"}))

{

sleep 60

}

 

Get-MailboxExportRequest -Mailbox Email_journal_user | Remove-MailboxExportRequest -Confirm:$false

Get-Mailbox -ID Email_journal_user | Search-Mailbox -SearchQuery 'subject:"*"' -deletecontent -force

 

Both parts with a while loop in the middle. It still left about 17 emails in the box afterwards, but they are probably just things archived after the fact and the odd bit not covered by -SearchQuery 'subject:"*"'.

 

Bold bits are the bits to change as they point to my system.

 

Thanks, and hope this helps others,

 

James

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...