Link to home
Start Free TrialLog in
Avatar of cyberleo2000
cyberleo2000Flag for United States of America

asked on

How can I export calendar content using exchange shell?

I tried using the command below to try to remove a meeting from a calendar, but, although the script runs with no errors, nothing is exported and the meeting remains in the calendar. What am I doing wrong?

Export-Mailbox -id jsmith -SubjectKeywords "Goals Review" -IncludeFolders "\Calendar" -StartDate "5/3/2012" -EndDate "5/5/2012" -DeleteContent -Targetmailbox "ExchangeAdmin" -TargetFolder JeanSmith -Confirm:$false
Avatar of ash007
ash007
Flag of India image

Can you please let me know if you want to remove meeting or want to export mailbox to PST
Your command is to delete the content of calendar not exporting. If you want to export the content to PST or other mailbox, do not use -DeleteContent

link:http://technet.microsoft.com/en-us/library/bb266964(v=exchg.80).aspx
Avatar of cyberleo2000

ASKER

Yes, I want to delete the content from the mailbox's calendar. I was under the impression that a targetmailbox or PST file switch is required. I am running the command on the exchange server and I do not have outlook installed on the exchange server so I used the targetmailbox switch.
here is another example: Export-Mailbox -id jsmith -subjectkeywords "Pickup at Store" -IncludeFolders "\Calendar" -StartDate "04/19/2010" -EndDate "04/21/2010" -DeleteContent

I ran this to try and delete an appointment in jsmith's calendar with that subject and it did not work, but there were no errors.

Below is some the status output I received in the powershell window

Options                          : DeleteSourceContent
SourceForestCredential           :
TargetForestCredential           :
TargetFolder                     :
PSTFilePath                      :
RsgMailboxGuid                   :
RsgMailboxLegacyExchangeDN       :
RsgMailboxDisplayName            :
RsgDatabaseGuid                  :
StandardMessagesDeleted          : 0
AssociatedMessagesDeleted        : 0
DumpsterMessagesDeleted          : 0
MoveType                         : DeleteOnly
MoveStage                        : Completed
StartTime                        : 4/18/2012 1:43:10 PM
EndTime                          : 4/18/2012 1:43:15 PM
StatusCode                       : 0
StatusMessage                    : Messages have been deleted from the source mailbox.
ReportFile                       : E:\Program Files\Microsoft\Exchange Server\Logging\MigrationLogs\export-Mailbox20120
                                   418-134253-8595452.xml
below is the log file output

/18/2012 1:42:53 PM] [0] Executing Command: 'Export-Mailbox -id jsmith -subjectkeywords "Pickup at Store" -IncludeFolders "\Calendar" -StartDate "04/19/2010" -EndDate "04/21/2010" -DeleteContent'
[4/18/2012 1:42:55 PM] [0] Searching objects "jsmith" of type "ADUser" under the root "$null".
[4/18/2012 1:42:56 PM] [0] Previous operation run on global catalog server 'MYDCSERVER.MYDOMAIN.com'.
[4/18/2012 1:42:56 PM] [0] Processing object "amer.MYDOMAIN.com/US/HUB/ATL-01/Users/Fernandez, Leonardo".
[4/18/2012 1:42:56 PM] [0] Searching objects "MYEXCHANGESERVER" of type "Server" under the root "$null".
[4/18/2012 1:42:56 PM] [0] Previous operation run on domain controller 'MYDCSERVER.MYDOMAIN.com'.
[4/18/2012 1:42:57 PM] [0] Searching objects "MYEXCHANGESERVER\SG18\ME200-MS18" of type "MailboxDatabase" under the root "$null".
[4/18/2012 1:42:57 PM] [0] Previous operation run on domain controller 'MYDCSERVER.MYDOMAIN.com'.
[4/18/2012 1:43:07 PM] [0] Ending processing.
[4/18/2012 1:43:07 PM] [0] [jsmith] The operation has started.
[4/18/2012 1:43:07 PM] [0] [jsmith] Approving object.
[4/18/2012 1:43:10 PM] [0] [jsmith] Trying to open mailbox:
      szServerLegacyDN: /o=MYDOMAIN/ou=Exchange Administrative Group (FYDIBOHF23SPDLT)/cn=Configuration/cn=Servers/cn=MYEXCHANGESERVER
      szUserLegacyDN: /o=MYDOMAIN/ou=First Administrative Group/cn=Recipients/cn=jsmith
      szServer: MYEXCHANGESERVER.MYDOMAIN.com
[4/18/2012 1:43:10 PM] [0] [jsmith] Open mailbox succeeded.
[4/18/2012 1:43:10 PM] [0] [jsmith] The operation has finished.
[4/18/2012 1:43:10 PM] [0] [jsmith] The operation has started.
[4/18/2012 1:43:10 PM] [0] [jsmith] Approving object.
[4/18/2012 1:43:13 PM] [0] [jsmith] Opening source mailbox.
[4/18/2012 1:43:13 PM] [0] [jsmith] Trying to open mailbox:
      szServerLegacyDN: /o=MYDOMAIN/ou=Exchange Administrative Group (FYDIBOHF23SPDLT)/cn=Configuration/cn=Servers/cn=MYEXCHANGESERVER
      szUserLegacyDN: /o=MYDOMAIN/ou=First Administrative Group/cn=Recipients/cn=jsmith
      szServer: MYEXCHANGESERVER.MYDOMAIN.com
[4/18/2012 1:43:13 PM] [0] [jsmith] Open mailbox succeeded.
[4/18/2012 1:43:13 PM] [0] [jsmith] Moving messages.
[4/18/2012 1:43:13 PM] [0] [jsmith] Exporting messages.
[4/18/2012 1:43:13 PM] [0] [jsmith] Merging messages.
[4/18/2012 1:43:15 PM] [0] [jsmith] 0 items could not be moved to the target mailbox.
[4/18/2012 1:43:15 PM] [0] [jsmith] Messages moved. Closing connections.
[4/18/2012 1:43:15 PM] [0] [jsmith] The operation has finished.
SOLUTION
Avatar of ash007
ash007
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Sending the exported data to a mailbox or pst file should not matter, the data should still be removed from the source mailbox. That said, I cannot use a PST file because I am running the command on the exchange server, hence, no Outlook.

Also, if I don't specifiy a Start and End date then all calendar items with that same subject will be removed. I only want to remove it from within that date range.
Are running on Exchange 2007 ? You can't run Export-Mailbox cmdlet on Exchange server.

To perform this procedure, the account you use must be delegated the following:
 Exchange Server Administrators role and local Administrators group for the source server and the target server
 
Full access to the source and target mailboxes
 

For more information about permissions, delegating roles, and the rights that are required to administer Exchange 2007, see Permission Considerations.

Also, before you perform this procedure, be aware of the following:
 To use the Export-Mailbox cmdlet, the source mailbox and target mailbox must be in the same forest. You cannot export data from a mailbox in one forest to a mailbox in a different forest.

You cannot export data from a public folder database.
 
To grant full access to a mailbox, use the Add-MailboxPermission cmdlet and specify FullAccess for the AccessRights parameter. For example, if Admin01 needs to export data from John's mailbox to a mailbox called Export, you must first run the following commands:






Copy


Add-MailboxPermission -Identity john -User Admin01 -AccessRights FullAccess
Add-MailboxPermission -Identity Export -User Admin01 -AccessRights FullAccess
 
To export data from an Exchange 2003 or Exchange 2000 mailbox, the account you use must be delegated the Exchange Administrator role for the administrative group in which the server resides.
 
To export data from a .pst file, you must run the Export-Mailbox cmdlet from a 32-bit computer that has the following installed:
 The 32-bit version of the Exchange management tools
 
Outlook 2003 Service Pack 2 (SP2) or Outlook 2007
 
For information about Exchange 2007 management tools 32-bit download, see Microsoft Exchange Server 2007 Management Tools (32-Bit).
 
If you export data to a folder in another mailbox, the target mailbox that you specify must exist before you run the command.


If you doesn't include -DeleteContent cmdlet, the data will not removed from source mailbox. Already tested.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I still do not understand why this command does not work?

Export-Mailbox -id jsmith -SubjectKeywords "Goals Review" -IncludeFolders "\Calendar" -StartDate "5/3/2012" -EndDate "5/5/2012" -DeleteContent -Targetmailbox "ExchangeAdmin" -TargetFolder JeanSmith -Confirm:$false
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Problem solved? What is your final cmdlet?
Export-Mailbox -id jsmith -SubjectKeywords "Goals Review" -IncludeFolders "\Calendar" -StartDate "5/3/2012" -EndDate "5/5/2012" -DeleteContent -Targetmailbox "ExchangeAdmin" -TargetFolder JeanSmith -Confirm:$false

It was not a problem with the cmdlet, it was a problem with the subject of the appointment, although I have no idea what that problem was. I ran the cmdlet against a number of other appointments and it worked just fine.