$password = "your_pw" | ConvertTo-SecureString -asPlainText -Force
$credential = New-Object System.Management.Automation.PSCredential("your_userid",$password)
$session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $credential -Authentication Basic -AllowRedirection
Import-PSSession $session -CommandName Get-Mailbox, Search-MailBox -AllowClobber
try
{
Get-MailBox | Search-Mailbox -SearchQuery 'From:[target_user] and kind:meetings' -TargetMailbox "[target_mailbox]" -TargetFolder "[target_folder]" -DeleteContent
}
catch
{
# Do nothing
}
Remove-PSSession $session
The target_mailbox is where the data destined to be removed is copied to. The target_folder is a folder name of your selection on the target_mailbox. Before the data is removed from the end users calendar, it is copied to the target_mailbox in the target_folder folder. Generally, this would be your account. When you start the script, you will see this folder show up in Outlook. Should you have to recover anything, you will find it in this account and folder.
No comments:
Post a Comment