cli-microsoft365
cli-microsoft365 copied to clipboard
New command: `m365 spo folder sharinglink add`
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 [email protected],[email protected]
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
- besides the usual naming and support for site-relative URL
- why don't we want to use
retainInheritedPermissions
as well? - any reason why in the scope we don't allow the
user
option? seems to be supported as well - the default response it return has complex object
{
"id": "123ABC",
"roles": ["write"],
"link": {
"type": "view",
"scope": "anonymous",
"webUrl": "https://1drv.ms/A6913278E564460AA616C71B28AD6EB6",
"application": {
"id": "1234",
"displayName": "Sample Application"
},
},
"hasPassword": true
}
which is a shame as we will lose a lot of useful info in the text
and csv
output mode. I wonder if it would be possible to customize the response for this mode to also print out this info 🤔 @pnp/cli-for-microsoft-365-maintainers any comments on that.
besides the above I don't currently see anything else
- 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.
Thanks for the feedback @Adam-it. I have implemented all the suggestions. Regarding the output, it's hard for me to judge.
@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?
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.
in this case, I would flatten the complex to return also type
, scope
, webUrl
and other properties
Can I work on this?
Definitely!