How can I configure SharePoint sharing link expiration settings with PowerShell?
Asked by
MellowCedar42
I want to configure tenant-wide SharePoint and OneDrive sharing link retention settings, such as setting the maximum organization sharing link expiration to 365 days, along with the recommended expiration values. Should I use the SharePoint Online PowerShell module or PnP PowerShell for this? Is the SharePoint Online module still supported, and is it expected to be removed? I can connect successfully with PnP PowerShell, but running Set-PnPTenant -CoreOrganizationSharingLinkMaxExpirationInDays 365 returns an error saying that no matching parameter exists. Are Get-SPOTenant and Get-PnPTenant showing the same tenant settings?
Answers
This appears to have been a missing-parameter issue in the PnP implementation rather than a problem with the tenant setting itself. Support for these parameters was added in newer nightly builds, so updating to a build that includes the fix should allow Set-PnPTenant to accept them. The expiration values should be chosen according to your organizationโs security and sharing policies; there is no universal number that fits every environment.
Reply to this answer
The PnP documentation lists these tenant parameters, so the first things to check are that PnP PowerShell is installed or updated correctly and that the connection is being made from an elevated PowerShell session. If the command still fails, include the complete error and the installed PnP PowerShell version, since parameter support can vary between releases.
MellowCedar42: The connection succeeds through Connect-PnPOnline, but Set-PnPTenant reports that it cannot find the CoreOrganizationSharingLinkMaxExpirationInDays parameter.
Reply to this answer
Add your answer
Answers are reviewed before publication.
AmberVale63: The example values were based on an internal company decision, not a generally recommended standard. It is best to have the business and security teams agree on the appropriate duration.