diff --git a/documentation/New-PnPVivaEngageCommunity.md b/documentation/New-PnPVivaEngageCommunity.md index 9104dfe02..0980d6384 100644 --- a/documentation/New-PnPVivaEngageCommunity.md +++ b/documentation/New-PnPVivaEngageCommunity.md @@ -15,7 +15,7 @@ Creates a Viva engage community ## SYNTAX ```powershell -New-PnPVivaEngageCommunity [[-DisplayName] [-Description] [-Privacy] ] [-Connection ] +New-PnPVivaEngageCommunity [[-DisplayName] [-Description] [-Privacy] ] [-Owners ] [-Connection ] ``` ## DESCRIPTION @@ -89,6 +89,20 @@ Accept pipeline input: True (ByValue) Accept wildcard characters: False ``` +### -Owners +The owners of the Viva engage community. This is mandatory if application permissions are used else the request will fail. + +```yaml +Type: String[] +Parameter Sets: (All) + +Required: False +Position: Named +Default value: None +Accept pipeline input: True (ByValue) +Accept wildcard characters: False +``` + ## RELATED LINKS [Microsoft 365 Patterns and Practices](https://aka.ms/m365pnp) diff --git a/documentation/Send-PnPMail.md b/documentation/Send-PnPMail.md index a26c8ee32..2f8f18fea 100644 --- a/documentation/Send-PnPMail.md +++ b/documentation/Send-PnPMail.md @@ -124,7 +124,7 @@ Allows defining what type of content is in the Body parameter. Defaults to HTML. ```yaml Type: MessageBodyContentType -Parameter Sets: Send through Microsoft Graph with attachments from SPO, Send through Microsoft Graph with attachments from local file system +Parameter Sets: Send through Microsoft Graph Accepted values: Html, Text Required: False @@ -153,7 +153,7 @@ The sender of the e-mail. When Microsoft Graph is used, this can be a user or a ```yaml Type: String -Parameter Sets: Send through Microsoft Graph with attachments from SPO, Send through Microsoft Graph with attachments from local file system +Parameter Sets: Send through Microsoft Graph Required: True Position: Named @@ -167,7 +167,7 @@ Allows defining what the importance of the e-mail is. Defaults to Normal. ```yaml Type: MessageImportanceType -Parameter Sets: Send through Microsoft Graph with attachments from SPO, Send through Microsoft Graph with attachments from local file system +Parameter Sets: Send through Microsoft Graph Accepted values: Low, Normal, High Required: False @@ -182,7 +182,7 @@ List of return addresses to use for the e-mail ```yaml Type: String[] -Parameter Sets: Send through Microsoft Graph with attachments from SPO, Send through Microsoft Graph with attachments from local file system +Parameter Sets: Send through Microsoft Graph Required: False Position: Named @@ -196,7 +196,7 @@ Allows indicating if the sent e-mail should be stored in the Sent Items of the m ```yaml Type: String[] -Parameter Sets: Send through Microsoft Graph with attachments from SPO, Send through Microsoft Graph with attachments from local file system +Parameter Sets: Send through Microsoft Graph Required: False Position: Named @@ -238,7 +238,7 @@ List of attachments from local file system to be uploaded and sent as attachment ```yaml Type: String[] -Parameter Sets: Send through Microsoft Graph with attachments from local file system +Parameter Sets: Send through Microsoft Graph Required: False Position: Named @@ -252,7 +252,7 @@ List of files from the SharePoint site collection to be sent as attachments. ```yaml Type: String[] -Parameter Sets: Send through Microsoft Graph with attachments from SPO +Parameter Sets: Send through Microsoft Graph Required: False Position: Named diff --git a/src/Commands/Utilities/SendMail.cs b/src/Commands/Utilities/SendMail.cs index 5917fbea0..54dc01304 100644 --- a/src/Commands/Utilities/SendMail.cs +++ b/src/Commands/Utilities/SendMail.cs @@ -10,63 +10,63 @@ namespace PnP.PowerShell.Commands.Utilities [Cmdlet(VerbsCommunications.Send, "PnPMail", DefaultParameterSetName = ParameterSet_SENDTHROUGHSPO)] public class SendMail : PnPWebCmdlet { - private const string ParameterSet_SENDTHROUGHGRAPH = "Send through Microsoft Graph with attachments from local file system"; private const string ParameterSet_SENDTHROUGHSPO = "Send through SharePoint Online"; - private const string ParameterSet_SENDTHROUGHGRAPHWITHFILES = "Send through Microsoft Graph with attachments from SPO"; + private const string ParameterSet_SENDTHROUGHGRAPH = "Send through Microsoft Graph"; [Parameter(Mandatory = true, ParameterSetName = ParameterSet_SENDTHROUGHGRAPH)] - [Parameter(Mandatory = true, ParameterSetName = ParameterSet_SENDTHROUGHGRAPHWITHFILES)] public string From; [Parameter(Mandatory = true, ParameterSetName = ParameterSet_SENDTHROUGHGRAPH)] [Parameter(Mandatory = true, ParameterSetName = ParameterSet_SENDTHROUGHSPO)] - [Parameter(Mandatory = true, ParameterSetName = ParameterSet_SENDTHROUGHGRAPHWITHFILES)] public string[] To; [Parameter(Mandatory = false, ParameterSetName = ParameterSet_SENDTHROUGHGRAPH)] [Parameter(Mandatory = false, ParameterSetName = ParameterSet_SENDTHROUGHSPO)] - [Parameter(Mandatory = false, ParameterSetName = ParameterSet_SENDTHROUGHGRAPHWITHFILES)] public string[] Cc; [Parameter(Mandatory = false, ParameterSetName = ParameterSet_SENDTHROUGHGRAPH)] [Parameter(Mandatory = false, ParameterSetName = ParameterSet_SENDTHROUGHSPO)] - [Parameter(Mandatory = false, ParameterSetName = ParameterSet_SENDTHROUGHGRAPHWITHFILES)] public string[] Bcc; [Parameter(Mandatory = true, ParameterSetName = ParameterSet_SENDTHROUGHGRAPH)] [Parameter(Mandatory = true, ParameterSetName = ParameterSet_SENDTHROUGHSPO)] - [Parameter(Mandatory = true, ParameterSetName = ParameterSet_SENDTHROUGHGRAPHWITHFILES)] public string Subject; [Parameter(Mandatory = true, ParameterSetName = ParameterSet_SENDTHROUGHGRAPH)] [Parameter(Mandatory = true, ParameterSetName = ParameterSet_SENDTHROUGHSPO)] - [Parameter(Mandatory = true, ParameterSetName = ParameterSet_SENDTHROUGHGRAPHWITHFILES)] public string Body; [Parameter(Mandatory = false, ParameterSetName = ParameterSet_SENDTHROUGHGRAPH)] - [Parameter(Mandatory = false, ParameterSetName = ParameterSet_SENDTHROUGHGRAPHWITHFILES)] public MessageImportanceType Importance; [Parameter(Mandatory = false, ParameterSetName = ParameterSet_SENDTHROUGHGRAPH)] - [Parameter(Mandatory = false, ParameterSetName = ParameterSet_SENDTHROUGHGRAPHWITHFILES)] public string[] ReplyTo; [Parameter(Mandatory = false, ParameterSetName = ParameterSet_SENDTHROUGHGRAPH)] - [Parameter(Mandatory = false, ParameterSetName = ParameterSet_SENDTHROUGHGRAPHWITHFILES)] public bool? SaveToSentItems; [Parameter(Mandatory = false, ParameterSetName = ParameterSet_SENDTHROUGHGRAPH)] - [Parameter(Mandatory = false, ParameterSetName = ParameterSet_SENDTHROUGHGRAPHWITHFILES)] public MessageBodyContentType? BodyContentType; [Parameter(Mandatory = false, ParameterSetName = ParameterSet_SENDTHROUGHGRAPH)] public string[] Attachments; - [Parameter(Mandatory = false, ParameterSetName = ParameterSet_SENDTHROUGHGRAPHWITHFILES)] + [Parameter(Mandatory = false, ParameterSetName = ParameterSet_SENDTHROUGHGRAPH)] public FilePipeBind[] Files; protected override void ExecuteCmdlet() { + // Runtime validation to prevent both attachment types being used together + if (ParameterSpecified(nameof(Attachments)) && ParameterSpecified(nameof(Files))) + { + ThrowTerminatingError(new ErrorRecord( + new PSArgumentException("You cannot use both -Attachments and -Files parameters together."), + "SendMailAttachmentConflict", + ErrorCategory.InvalidArgument, + this)); + return; + } + if (string.IsNullOrWhiteSpace(From)) { LogDebug("Sending e-mail through SharePoint Online");