Skip to content

Commit

Permalink
Merge pull request #2496 from KoenZomers/MakeAddPnPMicrosoft365GroupT…
Browse files Browse the repository at this point in the history
…oSiteNotRequireUrl

Changed `Add-PnPMicrosoft365GroupToSite` to no longer require `-Url`
  • Loading branch information
gautamdsheth authored Oct 26, 2022
2 parents 21b57cb + 092bd86 commit ffbb856
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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. [#2496](https://github.com/pnp/powershell/pull/2496)

### Removed

Expand Down
17 changes: 11 additions & 6 deletions documentation/Add-PnPMicrosoft365GroupToSite.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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)
8 changes: 6 additions & 2 deletions src/Commands/Admin/AddMicrosoft365GroupToSite.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@
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
{
[Cmdlet(VerbsCommon.Add, "PnPMicrosoft365GroupToSite")]
public class AddMicrosoft365GroupToSite: PnPAdminCmdlet
{
[Parameter(Mandatory = true)]
[Parameter(Mandatory = false)]
public string Url;

[Parameter(Mandatory = true)]
Expand Down Expand Up @@ -56,6 +55,11 @@ protected override void ExecuteCmdlet()
groupifyInformation.HubSiteId = HubSiteId;
}

if (!ParameterSpecified(nameof(Url)))
{
Url = Connection.Url;
}

Tenant.GroupifySite(Url, groupifyInformation);
}
}
Expand Down

0 comments on commit ffbb856

Please sign in to comment.