< Back

Remove-MgaMailAttachment

Sat Jan 18, 2020 4:42 pm

NAME Remove-MgaMailAttachment



SYNOPSIS

Remove attachment(s) from a email message(s) in Exchange Online using the graph api.





SYNTAX

Remove-MgaMailAttachment [-IncludeInlineAttachment] [-Force] [-User <String>] [-Token <AzureAccessToken>]

[-PassThru] [-WhatIf] [-Confirm] [<CommonParameters>]



Remove-MgaMailAttachment [-Message] <MessageParameter[]> [[-Name] <String>] [-IncludeInlineAttachment] [-Force]

[-User <String>] [-Token <AzureAccessToken>] [-PassThru] [-WhatIf] [-Confirm] [<CommonParameters>]



Remove-MgaMailAttachment [-Attachment] <AttachmentParameter[]> [-IncludeInlineAttachment] [-Force] [-User

<String>] [-Token <AzureAccessToken>] [-PassThru] [-WhatIf] [-Confirm] [<CommonParameters>]





DESCRIPTION

Remove attachment(s) from a email message(s) in Exchange Online using the graph api.





PARAMETERS

-Message <MessageParameter[]>

Carrier object for Pipeline input.

This can be the id of the message or a message object passed in.



Required? true

Position? 1

Default value

Accept pipeline input? true (ByValue, ByPropertyName)

Accept wildcard characters? false



-Attachment <AttachmentParameter[]>

Carrier object for Pipeline input.

This can be the id of the attachment or a attachment object passed in.



Required? true

Position? 1

Default value

Accept pipeline input? true (ByValue, ByPropertyName)

Accept wildcard characters? false



-Name <String>

The name of the attachment to delete.



Required? false

Position? 2

Default value *

Accept pipeline input? false

Accept wildcard characters? false



-IncludeInlineAttachment [<SwitchParameter>]

Also search and remove InlineAttachment.

Per default, only attachments outside a html body are recognized.



Required? false

Position? named

Default value False

Accept pipeline input? false

Accept wildcard characters? false



-Force [<SwitchParameter>]

Suppress any confirmation request and enforce removing attachment on any kind of message.



Required? false

Position? named

Default value False

Accept pipeline input? false

Accept wildcard characters? false



-User <String>

The user-account to access. Defaults to the main user connected as.

Can be any primary email name of any user the connected token has access to.



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Token <AzureAccessToken>

The token representing an established connection to the Microsoft Graph Api.

Can be created by using New-MgaAccessToken.

Can be omitted if a connection has been registered using the -Register parameter on New-MgaAccessToken.



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-PassThru [<SwitchParameter>]

Outputs the object to the console.



Required? false

Position? named

Default value False

Accept pipeline input? false

Accept wildcard characters? false



-WhatIf [<SwitchParameter>]

If this switch is enabled, no actions are performed but informational messages will be displayed that explain

what would happen if the command were to run.



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Confirm [<SwitchParameter>]

If this switch is enabled, you will be prompted for confirmation before executing any operations that change

state.



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS



OUTPUTS



NOTES





For addiontional information about Microsoft Graph API go to:

https://docs.microsoft.com/en-us/graph/ ... h-rest-1.0



-------------------------- EXAMPLE 1 --------------------------



PS C:\\>Get-MgaMailMessage -Folder Drafts | Remove-MgaMailAttachment



Delete attachment(s) from all mails in drafts folder of the user connected to through a token.









-------------------------- EXAMPLE 2 --------------------------



PS C:\\>Get-MgaMailMessage -Folder Drafts | Remove-MgaMailAttachment -Name "MyName*"



Delete attachment(s) with name MyName* from all mails in drafts folder of the user connected to through a token.









-------------------------- EXAMPLE 3 --------------------------



PS C:\\>Get-MgaMailMessage -Folder Drafts | Remove-MgaMailAttachment -IncludeInlineAttachment



Delete also "inline" attachments, like pictures in html mails from all emails in drafts folder of the user

connected to through a token.











RELATED LINKS