Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
By default, organization version history settings are applied to all new OneDrive accounts. As a SharePoint admin in Microsoft 365, you can set the version limits on OneDrive storage for a specific user.
Follow these steps to manage Version history limits for a site by using PowerShell.
Download the latest SharePoint Online Management Shell.
Note
If you installed a previous version of the SharePoint Online Management Shell, go to Add or remove programs and uninstall SharePoint Online Management Shell.
Connect to SharePoint as a SharePoint Administrator in Microsoft 365. To learn how, see Getting started with SharePoint Online Management Shell.
Run one of the following commands to manage Version history limits for a specific user:
| Action | PowerShell Command |
|---|---|
| View the version history limits set for a user | Get-SPOSite -Identity $siteUrl | fl Url, EnableAutoExpirationVersionTrim, ExpireVersionsAfterDays, MajorVersionLimit |
| Set automatic Version history limits for a user | Set-SPOSite -Identity $siteUrl -EnableAutoExpirationVersionTrim $true |
| Set manual limits with count and time parameters for a user | Set-SPOSite -Identity $siteUrl-EnableAutoExpirationVersionTrim $false-MajorVersionLimit <delete major versions exceeding limit>-MajorWithMinorVersionsLimit <number of major versions for which all minor versions will be kept>-ExpireVersionsAfterDays <delete versions exceeding time limit set in days> |
| Set manual limits with count with no expiration limit for a user | To set manual limits with count limits set the -ExpireVersionsAfterDays parameter to 0:Set-SPOSite -Identity $siteUrl-EnableAutoExpirationVersionTrim $false-MajorVersionLimit <delete major versions exceeding limit>-MajorWithMinorVersionsLimit <number of major versions for which all minor versions will be kept>-ExpireVersionsAfterDays 0 |
| Clear the existing Version history limits for a user Note: Clearing a setting for a user applies to new versions created on files stored on the user’s OneDrive account and doesn't trim existing versions. |
Remove-SPOSiteVersionPolicyJob -Identity $siteUrl |