?
Solved

Remove E-mails From Public Folders

Posted on 2014-10-30
6
Medium Priority
?
2,370 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 750 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 750 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

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

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…
Unified and professional email signatures help maintain a consistent company brand image to the outside world. This article shows how to create an email signature in Exchange Server 2010 using a transport rule and how to overcome native limitations …
In this video we show how to create a Shared Mailbox 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 Recipients >> Sha…
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
Suggested Courses

752 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