From 1ad4f5ca681e16c85f8e2c8a83503f9cbc6d60bc Mon Sep 17 00:00:00 2001 From: Koen Zomers Date: Wed, 26 Oct 2022 19:27:31 +0200 Subject: [PATCH 1/2] Changed the implementation to no longer require Url to be provided --- CHANGELOG.md | 1 + documentation/Add-PnPMicrosoft365GroupToSite.md | 17 +++++++++++------ .../Admin/AddMicrosoft365GroupToSite.cs | 8 ++++++-- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3011d4edb..72a167344 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -60,6 +60,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). - Improved `Connect-PnPOnline` with ACS method. Replace the usage of `WebRequest` with `HTTPClient`. [#2352](https://github.com/pnp/powershell/pull/2352) - Improved `Remove-PnPFieldFromContentType` cmdlet to ensure proper null check for non-existing fields. It will now throw proper `Field not found` error. [#2407](https://github.com/pnp/powershell/pull/2407) - Changed the Microsoft 365 Groups cmdlets to use the `v1.0` endpoint instead of the `beta` [#2426](https://github.com/pnp/powershell/pull/2426) +- Changed `Add-PnPMicrosoft365GroupToSite` to longer require the `-Url` parameter to be specified. If its not provided, the currently connected to site will be groupified. ### Removed diff --git a/documentation/Add-PnPMicrosoft365GroupToSite.md b/documentation/Add-PnPMicrosoft365GroupToSite.md index 0c572ef15..e5d3c47d0 100644 --- a/documentation/Add-PnPMicrosoft365GroupToSite.md +++ b/documentation/Add-PnPMicrosoft365GroupToSite.md @@ -35,7 +35,14 @@ This command allows you to add a Microsoft 365 Unified group to an existing clas Add-PnPMicrosoft365GroupToSite -Url "https://contoso.sharepoint.com/sites/FinanceTeamsite" -Alias "FinanceTeamsite" -DisplayName "My finance team site group" ``` -This will groupify the FinanceTeamsite +This will groupify the FinanceTeamsite at the provided URL + +### EXAMPLE 2 +```powershell +Add-PnPMicrosoft365GroupToSite -Alias "HRTeamsite" -DisplayName "My HR team site group" +``` + +This will groupify the currently connected to site ## PARAMETERS @@ -166,13 +173,13 @@ Accept wildcard characters: False ``` ### -Url -Url of the site to be connected to an Microsoft 365 Group +Url of the site to be connected to an Microsoft 365 Group. When not provided, the site currently being connected to will be used. ```yaml Type: String Parameter Sets: (All) -Required: True +Required: False Position: Named Default value: None Accept pipeline input: False @@ -181,6 +188,4 @@ Accept wildcard characters: False ## RELATED LINKS -[Microsoft 365 Patterns and Practices](https://aka.ms/m365pnp) - - +[Microsoft 365 Patterns and Practices](https://aka.ms/m365pnp) \ No newline at end of file diff --git a/src/Commands/Admin/AddMicrosoft365GroupToSite.cs b/src/Commands/Admin/AddMicrosoft365GroupToSite.cs index 51924de73..f6cdc39c4 100644 --- a/src/Commands/Admin/AddMicrosoft365GroupToSite.cs +++ b/src/Commands/Admin/AddMicrosoft365GroupToSite.cs @@ -4,7 +4,6 @@ using PnP.PowerShell.Commands.Base; using System.Management.Automation; using PnP.Framework.Sites; -using PnP.PowerShell.Commands.Base.PipeBinds; using System; namespace PnP.PowerShell.Commands.Admin @@ -12,7 +11,7 @@ namespace PnP.PowerShell.Commands.Admin [Cmdlet(VerbsCommon.Add, "PnPMicrosoft365GroupToSite")] public class AddMicrosoft365GroupToSite: PnPAdminCmdlet { - [Parameter(Mandatory = true)] + [Parameter(Mandatory = false)] public string Url; [Parameter(Mandatory = true)] @@ -56,6 +55,11 @@ protected override void ExecuteCmdlet() groupifyInformation.HubSiteId = HubSiteId; } + if (!ParameterSpecified(nameof(Url))) + { + Url = Connection.Url; + } + Tenant.GroupifySite(Url, groupifyInformation); } } From d7fc8c0a7c673841825d6020f6150caba38cc5c2 Mon Sep 17 00:00:00 2001 From: Koen Zomers Date: Wed, 26 Oct 2022 19:29:24 +0200 Subject: [PATCH 2/2] Added PR reference --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 72a167344..de6bb4a7b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -60,7 +60,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). - Improved `Connect-PnPOnline` with ACS method. Replace the usage of `WebRequest` with `HTTPClient`. [#2352](https://github.com/pnp/powershell/pull/2352) - Improved `Remove-PnPFieldFromContentType` cmdlet to ensure proper null check for non-existing fields. It will now throw proper `Field not found` error. [#2407](https://github.com/pnp/powershell/pull/2407) - Changed the Microsoft 365 Groups cmdlets to use the `v1.0` endpoint instead of the `beta` [#2426](https://github.com/pnp/powershell/pull/2426) -- Changed `Add-PnPMicrosoft365GroupToSite` to longer require the `-Url` parameter to be specified. If its not provided, the currently connected to site will be groupified. +- Changed `Add-PnPMicrosoft365GroupToSite` to longer require the `-Url` parameter to be specified. If its not provided, the currently connected to site will be groupified. [#2496](https://github.com/pnp/powershell/pull/2496) ### Removed