Remove-MapiItem

Description

Deletes one or more items from a specified folder.

Syntax

Note: Parameters in orange are optional.

Remove-MapiItem
-FolderMapiObject<Mapi.NET.Folder>
-ItemIDMapi.NET.EntryID[]
-HardDeleteSwitchParameter

Remove-MapiItem
-FolderMapiObject<Mapi.NET.Folder>
-MapiObjectMapiObject<Mapi.NET.EntryID>[]
-HardDeleteSwitchParameter

 

Parameters

FolderA Mapi.NET.Folder object within which to delete items
EntryIDA list of one or more Mapi.NET.EntryID objects representing items to be deleted from Folder
MapiObjectA list of one or more MapiObject<Mapi.NET.EntryID> objects representing items to be deleted from Folder
HardDeleteA SwitchParameter, which if present will cause the items to be *hard* deleted from the folder

Remarks

This cmdlet deletes one or more items in the folder supplied to the Folder parameter.

The EntryID objects can be retrieved by a call to Get-MapiContents or from the object.MapiObject.EntryID property of an item.  In addition, the cmdlet can auto-convert a hexadecimal string to an EntryID.

The MapiObject parameter is convenient for objects returned from Get-MapiContents.

Note that hard deletion of items depends upon the message store.  For example, items in a PST may not support this option while items in an Exchange mailbox may.

It is unlikely that deleting 1000s of items in a single call will succeed.  MAPI has internal buffers that have byte size limits.  If a large number of items need to be deleted, it is best to divide the list into smaller arrays that are then processed in a loop.

This cmdlet will prompt to execute unless -Confirm:$false is used.