pnp / cli-microsoft365

Manage Microsoft 365 and SharePoint Framework projects on any platform
https://aka.ms/cli-m365
MIT License
907 stars 317 forks source link

New command: Modify Site Sharing settings #6266

Open louderthanloud123 opened 3 weeks ago

louderthanloud123 commented 3 weeks ago

Usage

m365 spo site sharingpermission set [options]

Description

Control how a site and its components can be shared.

Options

Option Description
-u, --siteUrl <siteUrl> URL of the site collection.
--capability <capability> Define how the site is shared. Possible values: full, limited, ownersOnly.

Examples

Update the sharing capability for a site where only owners can share files and the site

m365 spo site sharingpermission set --siteUrl https://siteaddress.com/sites/sitename  --capability ownersOnly

Update the sharing capability for a site where only both owners and members can share files and the site

m365 spo site sharingpermission set --siteUrl https://siteaddress.com/sites/sitename  --capability full

Default properties

N/A

Additional Info

Docs remarks

When specifying capability, consider the following:

API request

To update this setting, we have to execute 2 requests.

Update web

PATCH https://contoso.sharepoint.com/sites/Playground/_api/Web
{
    "MembersCanShare": true
}

Update member group

PATCH https://contoso.sharepoint.com/sites/Playground/_api/Web/AssociatedMembergroup
{
    "AllowMembersEditMembership": true
}

When updating the sharing status of a site, the API requests above should be used with the values below:

Sharing status Update web value Update member group value
full true true
limited true false
ownersOnly false false
milanholemans commented 3 weeks ago

I suggest that we split this into 2 commands:

Let's keep this one for the sharing permissions.

milanholemans commented 3 weeks ago

I suggest the following:

Usage

m365 spo site sharing set [options]

Description

Control how things in a site can be shared.

Options

Option Description
-u, --siteUrl <siteUrl> URL of the site collection.
--capability <capability> Define how the site is shared. Possible values: full, limited, ownersOnly.

Examples

Update the sharing capability for a site where only owners can share files and the site

m365 spo site sharing set --siteUrl https://siteaddress.com/sites/sitename  --capability ownersOnly

Update the sharing capability for a site where only both owners and members can share files and the site

m365 spo site sharing set --siteUrl https://siteaddress.com/sites/sitename  --capability full

Default properties

N/A

Additional Info

Docs remarks

When specifying capability, consider the following:

API request

To update this setting, we have to execute 2 requests.

Update web

PATCH https://contoso.sharepoint.com/sites/Playground/_api/Web
{
    "MembersCanShare": true
}

Update member group

PATCH https://contoso.sharepoint.com/sites/Playground/_api/Web/AssociatedMembergroup
{
    "AllowMembersEditMembership": true
}

When updating the sharing status of a site, the API requests above should be used with the values below:

Sharing status Update web value Update member group value
full true true
limited true false
ownersOnly false false
milanholemans commented 3 weeks ago

@pnp/cli-for-microsoft-365-maintainers what do you think of the spec? It's about this setting in SharePoint:

image

Jwaegebaert commented 3 weeks ago

Good catch on splitting this into two commands. The specs look very clear to me!

milanholemans commented 3 weeks ago

Good catch on splitting this into two commands. The specs look very clear to me!

Ok, opening it up then.