Skip to main content

spo file sharinglink set

Updates a sharing link of a file

Usage

m365 spo file sharinglink set [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 or fileId but not both.

--fileId [fileId]

The UniqueId (GUID) of the file. Specify either fileUrl or fileId but not both.

--id <id>

The ID of the sharing link.

--expirationDateTime <expirationDateTime>

The date and time to set the expiration. This should be defined as a valid ISO 8601 string. This options only works for anonymous links.

-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 is options.

--query [query]

JMESPath query string. See http://jmespath.org/ for more information and examples.

-o, --output [output]

Output type. json, text, csv, md, none. Default json.

--verbose

Runs command with verbose logging.

--debug

Runs command with debug logging.

Examples

Updates an anonymous sharing link from a file by a specified site-relative URL with the expirationDateTime parameter.

m365 spo file sharinglink set --webUrl https://contoso.sharepoint.com --fileUrl "/sites/demo/Shared Documents/Document.docx" --id 7c9f97c9-1bda-433c-9364-bb83e81771ee --expirationDateTime "2023-01-09T16:57:00.000Z"

Updates an anonymous sharing link from a file by id with the expirationDateTime parameter.

m365 spo file sharinglink set --webUrl https://contoso.sharepoint.com --fileId daebb04b-a773-4baa-b1d1-3625418e3234 --id 7c9f97c9-1bda-433c-9364-bb83e81771ee --expirationDateTime "2023-01-09T16:57:00.000Z"

Response

{
"id": "7c9f97c9-1bda-433c-9364-bb83e81771ee",
"roles": [
"read"
],
"expirationDateTime": "2023-02-09T16:57:00Z",
"hasPassword": false,
"grantedToIdentitiesV2": [],
"grantedToIdentities": [],
"link": {
"scope": "anonymous",
"type": "view",
"webUrl": "https://contoso.sharepoint.com/:b:/g/EbZx4QPyndlGp6HV-gvSPksBftmUNAiXjm0y-_527_fI9g",
"preventsDownload": false
}
}
CTRL + M