From 2eb5aa46f9ad059d966b0f42f99ce326e656628e Mon Sep 17 00:00:00 2001 From: Marc Studer <31045631+Studermarc@users.noreply.github.com> Date: Mon, 6 Feb 2023 16:25:36 +0100 Subject: [PATCH 1/5] Update AddTeamsChannel.cs Changed the "OwnerUPN" to Mandatory = false for the "Specific" Parameter Set. Setting this Parameted to Mandadory is preventing Standard Channels to be created with the "ChannelType" Parameter, as it will always ask for an OwnerUPN, whereas none should be required to begin with. Also correcting a small typo in the obsolete message for the "Private" switch --- src/Commands/Teams/AddTeamsChannel.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Commands/Teams/AddTeamsChannel.cs b/src/Commands/Teams/AddTeamsChannel.cs index 9593cff26..1709f2913 100644 --- a/src/Commands/Teams/AddTeamsChannel.cs +++ b/src/Commands/Teams/AddTeamsChannel.cs @@ -33,13 +33,13 @@ public class AddTeamsChannel : PnPGraphCmdlet public string Description; [Parameter(Mandatory = true, ParameterSetName = ParameterSET_PRIVATE)] - [Obsolete("Use TeamMembershipType instead.")] + [Obsolete("Use ChannelType instead.")] public SwitchParameter Private; [Parameter(Mandatory = true, ParameterSetName = ParameterSET_SPECIFIC)] public TeamsChannelType ChannelType; - [Parameter(Mandatory = true, ParameterSetName = ParameterSET_SPECIFIC)] + [Parameter(Mandatory = false, ParameterSetName = ParameterSET_SPECIFIC)] [Parameter(Mandatory = true, ParameterSetName = ParameterSET_PRIVATE)] public string OwnerUPN; @@ -84,4 +84,4 @@ protected override void ExecuteCmdlet() } } } -} \ No newline at end of file +} From a60b039fe118bba267fb43221be5b603da621141 Mon Sep 17 00:00:00 2001 From: Koen Zomers Date: Wed, 15 Feb 2023 11:46:56 +0100 Subject: [PATCH 2/5] Added changelog entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6126a68ba..c4e47e029 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -50,6 +50,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). - `Connect-PnPOnline` will now throw a much clearer error message if the site to be connected doesn't exist when using the legacy Client Id with Secret (ACS) authentication mode. [#2707](https://github.com/pnp/powershell/pull/2707) - Properties of `Get-PnPAzureADServicePrincipal` are now all typed instead of some of them returning unparsed JSON fragments. [#2717](https://github.com/pnp/powershell/pull/2717) - Marked `Get-PnPSubscribeSharePointNewsDigest` and `Set-PnPSubscribeSharePointNewsDigest` as obsolete as the implementation behind these features has been changed in SharePoint Online causing them no longer to work. At present, there's no alternative for this that we can call into thus we will have to remove these in a future version. [#2720](https://github.com/pnp/powershell/pull/2720) +- Changed `Add-PnPTeamsChannel` to no longer require an `-OwnerUPN` to be provided when specifying `-ChannelType Standard` [#2786](https://github.com/pnp/powershell/pull/2786) ### Removed From 046d39014e4482e341d71364260a228e49c9ee49 Mon Sep 17 00:00:00 2001 From: Koen Zomers Date: Wed, 15 Feb 2023 11:47:14 +0100 Subject: [PATCH 3/5] Changed to using nameof to aid in potential renames in the future --- src/Commands/Teams/AddTeamsChannel.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Commands/Teams/AddTeamsChannel.cs b/src/Commands/Teams/AddTeamsChannel.cs index 1709f2913..a0085f888 100644 --- a/src/Commands/Teams/AddTeamsChannel.cs +++ b/src/Commands/Teams/AddTeamsChannel.cs @@ -33,7 +33,7 @@ public class AddTeamsChannel : PnPGraphCmdlet public string Description; [Parameter(Mandatory = true, ParameterSetName = ParameterSET_PRIVATE)] - [Obsolete("Use ChannelType instead.")] + [Obsolete($"Use {nameof(ChannelType)} instead.")] public SwitchParameter Private; [Parameter(Mandatory = true, ParameterSetName = ParameterSET_SPECIFIC)] From 21cab2149905b4873ea70bd2e7610d86fdc8a46e Mon Sep 17 00:00:00 2001 From: Koen Zomers Date: Wed, 15 Feb 2023 12:17:02 +0100 Subject: [PATCH 4/5] Slightly different approach but same outcome --- src/Commands/Teams/AddTeamsChannel.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Commands/Teams/AddTeamsChannel.cs b/src/Commands/Teams/AddTeamsChannel.cs index a0085f888..47c782321 100644 --- a/src/Commands/Teams/AddTeamsChannel.cs +++ b/src/Commands/Teams/AddTeamsChannel.cs @@ -36,10 +36,11 @@ public class AddTeamsChannel : PnPGraphCmdlet [Obsolete($"Use {nameof(ChannelType)} instead.")] public SwitchParameter Private; + [Parameter(Mandatory = false, ParameterSetName = ParameterSET_STANDARD)] [Parameter(Mandatory = true, ParameterSetName = ParameterSET_SPECIFIC)] public TeamsChannelType ChannelType; - [Parameter(Mandatory = false, ParameterSetName = ParameterSET_SPECIFIC)] + [Parameter(Mandatory = true, ParameterSetName = ParameterSET_SPECIFIC)] [Parameter(Mandatory = true, ParameterSetName = ParameterSET_PRIVATE)] public string OwnerUPN; From b66a6ac822f4c46ade081284130dbe4b0c9da9ec Mon Sep 17 00:00:00 2001 From: Koen Zomers Date: Wed, 15 Feb 2023 12:24:51 +0100 Subject: [PATCH 5/5] Adding enforcement to provide the OwnerUPN when not specifying the Standard channel type --- src/Commands/Teams/AddTeamsChannel.cs | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/Commands/Teams/AddTeamsChannel.cs b/src/Commands/Teams/AddTeamsChannel.cs index 47c782321..8041bc7a4 100644 --- a/src/Commands/Teams/AddTeamsChannel.cs +++ b/src/Commands/Teams/AddTeamsChannel.cs @@ -38,7 +38,7 @@ public class AddTeamsChannel : PnPGraphCmdlet [Parameter(Mandatory = false, ParameterSetName = ParameterSET_STANDARD)] [Parameter(Mandatory = true, ParameterSetName = ParameterSET_SPECIFIC)] - public TeamsChannelType ChannelType; + public TeamsChannelType ChannelType = TeamsChannelType.Standard; [Parameter(Mandatory = true, ParameterSetName = ParameterSET_SPECIFIC)] [Parameter(Mandatory = true, ParameterSetName = ParameterSET_PRIVATE)] @@ -56,15 +56,9 @@ protected override void ExecuteCmdlet() throw new PSArgumentException("Group not found"); } - switch (ParameterSetName) + if(ChannelType != TeamsChannelType.Standard && !ParameterSpecified(nameof(OwnerUPN))) { - case ParameterSET_PRIVATE: - ChannelType = TeamsChannelType.Private; - break; - - case ParameterSET_STANDARD: - ChannelType = TeamsChannelType.Standard; - break; + throw new PSArgumentException("OwnerUPN is required when using the non standard channel type", nameof(OwnerUPN)); } try