Solved

Remove E-mails From Public Folders

Posted on 2014-10-30
6
2,168 Views
Last Modified: 2014-11-11
Hello Experts.  
To remove an e-mail from all mailboxes I use this command.

Get-Mailbox | Search-Mailbox -SearchQuery "From:'XXXX'" -LogOnly -TargetMailbox administrator  -TargetFolder Inbox
and
Get-Mailbox | Search-Mailbox -SearchQuery "From:'XXXX'" -DeleteContent.

This does not hit my Public Folders.   I am trying to write a basic command to also remove e-mails from Public Mail Enabled Folders.  

Get-PublicFolder | Search-Mailbox -SearchQuery "From:'XXX'" -LogOnly -TargetMailbox administrator -TargetFolder \research

Cannot process argument transformation on parameter 'Identity'. Cannot convert the "\" value of type "Microsoft.Exchange.Data.Mapi.PublicFolder Id" to type "Microsoft.Exchange.Configuration.Tasks.MailboxOrMailUserIdParameter".
    + CategoryInfo          : InvalidData: (Microsoft.Excha...pi.PublicFolder:PSObject) [Search-Mailbox], ParameterBin    din...mationException     + FullyQualifiedErrorId : ParameterArgumentTransformationError,Search-Mailbox

Any Suggestions ??

Thank you in advance for your assistance.
0
Comment
Question by:cnetwiz
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 7

Expert Comment

by:Satyendra Sharma
ID: 40414039
0
 

Author Comment

by:cnetwiz
ID: 40414130
Hello,
I already reviewed the first site.  
The purpose of this script is not to move but to delete a mail item from ALL public folders identified by similiar Subject or From as my example below shows:
Get-PublicFolder | Search-Mailbox -SearchQuery "From:'xxxx'" -LogOnly -TargetMailbox  administrator -TargetFolder "\Public Folders\All Public Folders\"

I can successfully run a smiliar script on the Exchange Mailboxes and it works perfectly.
Get-Mailbox | Search-Mailbox -SearchQuery "From:'XXXX'" -LogOnly -TargetMailbox administrator  -TargetFolder Inbox

When I run a Public Folder item,  I keep getting errors.  

I am trying to do the same thing but to the Public Folders.

Cannot process argument transformation on parameter 'Identity'. Cannot convert the "\" value of type "Microsoft.Exchange.Data.Mapi.PublicFolder Id" to type "Microsoft.Exchange.Configuration.Tasks.MailboxOrMailUserIdParameter".
     + CategoryInfo          : InvalidData: (Microsoft.Excha...pi.PublicFolder:PSObject) [Search-Mailbox], ParameterBin    din...mationException     + FullyQualifiedErrorId : ParameterArgumentTransformationError,Search-Mailbox
0
 
LVL 27

Accepted Solution

by:
Steve earned 250 total points
ID: 40434554
you cannot just specify a top level public folder (ie "\") as exchange has no way to translate that to the entire folder structure.

try getting the command to work on a specific folder first to check the command will actually work as you want it to.

Then have a look at the Microsoft provided script that adds permissions to public folders:
AddUsersToPFRecursive.ps1 (should be in your scripts folder)

This Powershell script actually gets a full public folder list and then applies the required permission to each folder one at a time.
To achieve what you need you'll have to do the same by recursively searching each folder. Use AddUsersToPFRecursive.ps1 as a starting point.
0
 
LVL 16

Assisted Solution

by:Rajitha Chimmani
Rajitha Chimmani earned 250 total points
ID: 40436056
You are getting this error as Search-Mailbox command works only against a mailbox and hence it does not recognize "\" as a valid object.

As I know, there is no direct command to delete items from a public folder using powershell. I have not seen one yet but I guess its possible through VB
0
 

Author Closing Comment

by:cnetwiz
ID: 40436117
I have discovered that deleting items from All Public Folders is not possible unless it is with a VB Script.   With the many Public Folders existing in our organizaiton, I will open a Pay Ticket with Microsoft to see what tricks they have up their sleeves.   I will gladly post any suggestions and resolutions from Microsoft here.     Thank you .
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A list of top three free exchange EDB viewers that helps the user to extract a mailbox from an unmounted .edb file and get a clear preview of all emails & other items with just a single click on mailboxes.
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
To show how to create a transport rule in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Mail Flow >> Rules tab.:  To cr…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question