pnp / cli-microsoft365

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

New command: `m365 spo folder sharinglink add` #5963

Open MathijsVerbeeck opened 3 months ago

MathijsVerbeeck commented 3 months ago

Usage

m365 spo folder sharinglink add [options]

Description

Creates a new sharing link to a folder

Options

Option Description
-u, --webUrl <webUrl> The URL of the site where the file is located
--folderUrl [folderUrl] The server- or site-relative decoded URL of the folder. Specify either folderUrl or folderId but not both
--folderId [folderId] The unique ID (GUID) of the folder. Specify either folderUrl or folderId but not both
--type <type> The type of sharing link to create. Either view or edit
--expirationDateTime [expirationDateTime] The date and time to set the expiration. This should be defined as a valid ISO 8601 string
--scope [scope] Optional. The scope of link to create. Either anonymous, organization or users. If not specified, the default of the organization will be used
--retainInheritedPermissions [retainInheritiedPermissions] Optional. If true, any existing inherited permissions are retained on the shared item when sharing this item for the first time. If false, all existing permissions are removed when sharing for the first time.
--recipients [recipients] Comma separated list of users with whom we wish to share the item with. Required when using scope users

Examples

Creates a view-only anonymous sharing link of a folder by id

m365 spo folder sharinglink add --webUrl https://contoso.sharepoint.com/sites/demo --folderId daebb04b-a773-4baa-b1d1-3625418e3234 --type view --scope anonymous

Creates an edit organization sharing link of a folder by url with a specific expiration date.

m365 spo folder sharinglink add --webUrl https://contoso.sharepoint.com/sites/demo --shareId 123ABC --folderUrl /sites/demo/shared%20documents/Folder --type edit --scope organization --expirationDateTime '2022-11-30T00:00:00Z'

Creates a user sharing link of a folder by id

m365 spo folder sharinglink add --webUrl https://contoso.sharepoint.com/sites/demo --folderId daebb04b-a773-4baa-b1d1-3625418e3234 --type view --scope users --recipients john@contoso.com,doe@contoso.com

Default properties

No response

Additional Info

The API call to create a sharing link can be found on the following documentation: https://learn.microsoft.com/en-us/graph/api/driveitem-createlink?view=graph-rest-1.0

Adam-it commented 2 months ago

besides the above I don't currently see anything else

MathijsVerbeeck commented 2 months ago
  • any reason why in the scope we don't allow the user option? seems to be supported as well

It is supported now indeed. I'll add this to the scope, however this requires another option for the recipients.

MathijsVerbeeck commented 2 months ago

Thanks for the feedback @Adam-it. I have implemented all the suggestions. Regarding the output, it's hard for me to judge.

Jwaegebaert commented 2 months ago

@milanholemans, if I recall, we talked a while ago about formatting nested properties for the text output. We ended up creating a custom property (#5900). What was the decision on handling these situations moving forward?

milanholemans commented 2 months ago

I think for the time being, it's ok to manipulate the result object for text etc. But in the future there will probably another way of working which we can't do right now.

Adam-it commented 2 months ago

in this case, I would flatten the complex to return also type, scope, webUrl and other properties

Saurabh7019 commented 2 months ago

Can I work on this?

milanholemans commented 2 months ago

Definitely!