< Back
Remove-MgaMailMessage
Post
NAME Remove-MgaMailMessage
SYNOPSIS
Remove message(s) in Exchange Online using the graph api.
SYNTAX
Remove-MgaMailMessage [-Message] <MessageParameter[]> [-Force] [-User <String>] [-Token <AzureAccessToken>]
[-PassThru] [-WhatIf] [-Confirm] [<CommonParameters>]
DESCRIPTION
Remove message(s) in Exchange Online using the graph api.
ATTENTION! The command does what it is name to!
The message will not be moved to 'deletedObjects', it will be deleted.
PARAMETERS
-Message <MessageParameter[]>
The message to be removed.
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
-Force [<SwitchParameter>]
If specified the user will not prompted on confirmation.
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 token 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
MSGraph.Exchange.Mail.Message
-------------------------- EXAMPLE 1 --------------------------
PS C:\\>Remove-MgaMailMessage -Message $message
Removes message represented by the variable $message.
This example will purge (the first 100 messages in) the inbox.
You will be prompted for confirmation.
The variable $message can be represent:
PS C:\\> $message = Get-MgaMailMessage -Folder Inbox
-------------------------- EXAMPLE 2 --------------------------
PS C:\\>$message | Remove-MgaMailMessage -Force
Removes message represented by the variable $message.
This example will purge (the first 100 messages in) the inbox.
ATTENTION, there will be NO prompt for confirmation!
The variable $mails can be represent:
PS C:\\> $message = Get-MgaMailMessage -Folder Inbox
RELATED LINKS
SYNOPSIS
Remove message(s) in Exchange Online using the graph api.
SYNTAX
Remove-MgaMailMessage [-Message] <MessageParameter[]> [-Force] [-User <String>] [-Token <AzureAccessToken>]
[-PassThru] [-WhatIf] [-Confirm] [<CommonParameters>]
DESCRIPTION
Remove message(s) in Exchange Online using the graph api.
ATTENTION! The command does what it is name to!
The message will not be moved to 'deletedObjects', it will be deleted.
PARAMETERS
-Message <MessageParameter[]>
The message to be removed.
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
-Force [<SwitchParameter>]
If specified the user will not prompted on confirmation.
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 token 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
MSGraph.Exchange.Mail.Message
-------------------------- EXAMPLE 1 --------------------------
PS C:\\>Remove-MgaMailMessage -Message $message
Removes message represented by the variable $message.
This example will purge (the first 100 messages in) the inbox.
You will be prompted for confirmation.
The variable $message can be represent:
PS C:\\> $message = Get-MgaMailMessage -Folder Inbox
-------------------------- EXAMPLE 2 --------------------------
PS C:\\>$message | Remove-MgaMailMessage -Force
Removes message represented by the variable $message.
This example will purge (the first 100 messages in) the inbox.
ATTENTION, there will be NO prompt for confirmation!
The variable $mails can be represent:
PS C:\\> $message = Get-MgaMailMessage -Folder Inbox
RELATED LINKS