spo file sharinglink add
Creates a new sharing link for a file
Usage
m365 spo file sharinglink add [options]
Options
-u, --webUrl <webUrl>
The URL of the site where the file is located.
--fileUrl [fileUrl]
The server- or site-relative decoded URL of the file. Specify either
fileUrl
orfileId
but not both.--fileId [fileId]
The UniqueId (GUID) of the file. Specify either
fileUrl
orfileId
but not both.--type <type>
The type of sharing link to create. Either
view
oredit
.--expirationDateTime [expirationDateTime]
The date and time to set the expiration. This should be defined as a valid ISO 8601 string.
--scope [scope]
The scope of link to create. Either
anonymous
ororganization
. If not specified, the default of the organization will be used.
-h, --help [help]
Output usage information. Optionally, specify which section of command's help you want to see. Allowed values are
options
,examples
,remarks
,response
,full
. Default isoptions
.--query [query]
JMESPath query string. See http://jmespath.org/ for more information and examples.
-o, --output [output]
Output type.
json
,text
,csv
,md
,none
. Defaultjson
.--verbose
Runs command with verbose logging.
--debug
Runs command with debug logging.
Examples
Creates a sharing link of a specific type for a file by id.
m365 spo file sharinglink add --webUrl https://contoso.sharepoint.com --fileId daebb04b-a773-4baa-b1d1-3625418e3234 --type view
Creates a sharing link of a specific type for a file by url.
m365 spo file sharinglink add --webUrl https://contoso.sharepoint.com --fileUrl "/sites/demo/Shared Documents/Test1.docx" --type edit
Creates a sharing link of a file by url with type, scope and expirationDateTime parameter.
m365 spo file sharinglink add --webUrl https://contoso.sharepoint.com --fileUrl "/sites/demo/Shared Documents/Test1.docx" --type edit --scope anonymous --expirationDateTime "2023-01-09T16:20:00Z"
Response
- JSON
- Text
- CSV
- Markdown
{
"id": "1e581e93-609e-4077-8152-c43865db684c",
"roles": [
"read"
],
"expirationDateTime": "2023-10-01T07:00:00Z",
"hasPassword": false,
"link": {
"scope": "anonymous",
"type": "view",
"webUrl": "https://contoso.sharepoint.com/:b:/g/EbZx4QPyndlGp6HV-gvSPksBSyMcgRPtyAxqqNAeiEp1kg",
"preventsDownload": false
}
}
hasPassword : false
expirationDateTime: 2023-10-01T07:00:00Z
id : 1e581e93-609e-4077-8152-c43865db684c
link : {"scope":"anonymous","type":"view","webUrl":"https://contoso.sharepoint.com/:b:/g/EbZx4QPyndlGp6HV-gvSPksBSyMcgRPtyAxqqNAeiEp1kg","preventsDownload":false}
roles : ["read"]
id,expirationDateTime,roles,hasPassword,link
1e581e93-609e-4077-8152-c43865db684c,2023-10-01T07:00:00Z,"[""read""]",,"{""scope"":""anonymous"",""type"":""view"",""webUrl"":""https://contoso.sharepoint.com/:b:/g/EbZx4QPyndlGp6HV-gvSPksBSyMcgRPtyAxqqNAeiEp1kg"",""preventsDownload"":false}"
# spo file sharinglink add --webUrl "https://contoso.sharepoint.com/sites/demo" --fileUrl "/sites/demo/Shared Documents/logo.jpg" --type "edit" --scope "anonymous" --expirationDateTime "2023-12-12T16:20:00Z"
Date: 10/3/2023
## 9239171b-d85c-4206-a852-45e8d61f9052
Property | Value
---------|-------
id | 9239171b-d85c-4206-a852-45e8d61f9052
shareId | u!aHR0cHM6Ly9uYWNoYW4zNjUuc2hhcmVwb2ludC5jb20vOmk6L3MvU1BEZW1vL0VZQ09MTEoydWs1QWlQcHoyX1gwRjhBQkdGSXZXbG1aaDdjZ1BCNXc2WGQxQ2c
expirationDateTime | 2023-12-12T16:20:00Z
hasPassword | false