Recently added feature to SharePoint Online allows administrators to set the maximum expiration duration for documents shared via anonymous shared links. The maximum expiration period for anonymous shared links can be set by setting the RequireAnonymousLinksExpireInDays parameter of Set-SPOTenant cmdlet from SharePoint Online Management shell. The mandatory expiration duration is set at tenant level and therefore will affect all the links that are shared anonymously.
If the maximum expiration duration is not set users would be able to create anonymous share links
that can be set to any date or create links that would never expires.
Below are the steps for setting mandatory expiration for anonymous links
1. Connect to SharePoint online tenant from SharePoint Online management shell. Version 16.9.4915.1200 of SharePoint Online Management shell is required for this feature. You can download it from here
2. Execute the Set-SPOTenant cmdlet with the RequireAnonymousLinksExpireInDays and the value for expiration duration
E.g. Set-SPOTenant RequireAnonymousLinksExpireInDays 30
The value range for expiration duration is 0 to 730
3. Once the mandatory expiration duration is set , when users try to share a document with anonymous link the expiration date would be automatically set to the value of current date plus the expiration duration.
4. Users can change the expiration date by clicking the Change link and providing a value for expiration days.
5. If a user tries to set a value more than the maximum duration set, an error indicating that the expiration date cannot exceed the organizational policy would be shown.
6. To reset the expiration duration to default execute the Set-SPOTenant cmdlet with a value of 0 to RequireAnonymousLinksExpireInDays parameter.