How to Free Up Storage in SharePoint Online Using Intelligent Versioning and PowerShell
So I’ve gotten more and more questions from users and client how to free up storage in their enviroment and I didn’t see and good post about how to do it, so I wrote a blogppost 🙂
Introduction
Freeing Storage in SharePoint Online Using Intelligent Versioning and PowerShell Automation
As organizations increasingly adopt SharePoint Online for collaboration and document management, managing storage efficiently becomes a critical challenge. One significant contributor to storage consumption is SharePoint’s versioning feature, which creates multiple versions of documents, leading to storage bloat over time.
In this post, we’ll discuss how to intelligently manage file versioning in SharePoint Online and automate the cleanup of old versions using PowerShell. By the end, you’ll have a clear strategy for maintaining healthy storage and managing SharePoint’s powerful versioning features effectively.
Understanding SharePoint Online Versioning
Versioning in SharePoint Online allows users to save multiple copies of documents as they get revised. This is essential for tracking changes, restoring earlier versions, and enabling collaboration. However, if not managed properly, the version history of documents can accumulate rapidly, consuming valuable storage space.
By default, SharePoint retains all versions of a document. Over time, this can lead to excessive storage usage, increased costs, and slower performance. This is where Intelligent Versioning becomes a useful strategy.
What is Intelligent Versioning?
Intelligent Versioning refers to a smart strategy that helps balance retaining valuable document history while freeing up unnecessary storage. Rather than keeping all document versions indefinitely, Intelligent Versioning helps ensure that only recent and important versions are retained, while older versions are deleted to conserve space.
This approach helps you optimize your SharePoint storage while preserving important data.
How Intelligent Versioning Works
Intelligent Versioning introduces a feature called automatic version thinning, which gradually trims older document versions while preserving key timestamps. Here’s how it works:
First 30 Days: All versions are kept.
From 30 to 180 Days: Hourly or daily versions are stored.
Beyond 180 Days: Weekly versions are kept indefinitely.
By using this automatic thinning approach, Microsoft reports that you can reduce version storage usage by up to 96% in some cases, without compromising users’ ability to access important historical versions.
My personal experience, I’ve seen storage saved 30-60% from various clients!
Benefits of Intelligent Versioning
Optimize Storage Costs: By deleting outdated versions, you reduce storage consumption, keeping within limits and potentially lowering costs.
Improve Performance: With fewer document versions stored, searches and retrieval times are faster.
Maintain Data Integrity: Intelligent Versioning ensures you delete only unnecessary versions while keeping critical ones intact.
How to Enable Intelligent Versioning
To enable Intelligent Versioning across your SharePoint Online tenant, use the following PowerShell command:
# Connect to SharePoint Online
$adminSiteUrl = “https://<tenant>-admin.sharepoint.com”
Connect-SPOService -Url $adminSiteUrl
# Enable Intelligent versioning
Set-SPOTenant -EnableVersionExpirationSetting $true
PnP Powershell:
# Install and Import PnP PowerShell module if not installed
# Install-Module -Name “PnP.PowerShell”
# Connect to SharePoint Online Admin Center
$adminSiteUrl = “https://<tenant>-admin.sharepoint.com”
Connect-PnPOnline -Url $adminSiteUrl -Interactive
# Enable Intelligent Versioning
Set-PnPTenant -EnableVersionExpirationSetting $true
Once enabled, this will apply Intelligent Versioning to all new files in SharePoint document libraries. You can verify this setting in the Admin Center under Versioning Settings.
Automating Version Cleanup Using PowerShell
While Intelligent Versioning applies to new documents, older files require manual intervention. Managing versions manually across multiple sites can be a tedious task. Fortunately, PowerShell allows you to automate the process.
Using the New-SPOSiteFileVersionBatchDeleteJob cmdlet, you can create batch deletion jobs to remove document versions older than a specified date.
Prerequisites:
SharePoint Online Administrator permissions.
SharePoint Online Management Shell installed.
PowerShell Script: Automating Version Cleanup
Here’s a PowerShell script that retrieves all site collections in your SharePoint Online tenant and creates a batch delete job for document versions older than 365 days:
# Connect to SharePoint Online
$adminSiteUrl = “https://<tenant>-admin.sharepoint.com”
Connect-SPOService -Url $adminSiteUrl
# Get all site collections
$siteCollections = Get-SPOSite -Limit All
# Loop through each site collection
foreach ($site in $siteCollections) {
Write-Host “Processing site: $($site.Url)”
# Create a batch delete job for versions older than 365 days
try {
New-SPOSiteFileVersionBatchDeleteJob -Identity $site.Url -DeleteBeforeDays 365 -confirm:$false
Write-Host “Batch delete job created for site: $($site.Url)”
}
catch {
Write-Host “Error creating batch delete job for site: $($site.Url)”
Write-Host $_.Exception.Message
}
}
# Disconnect from SharePoint Online
Disconnect-SPOService
PnP Powershell:
# Install the PnP PowerShell module if not already installed
# Install-Module -Name “PnP.PowerShell”
# Connect to SharePoint Online
$adminSiteUrl = “https://<tenant>-admin.sharepoint.com”
Connect-PnPOnline -Url $adminSiteUrl -Interactive
# Get all site collections
$siteCollections = Get-PnPTenantSite -IncludeOneDriveSites -Limit All
# Loop through each site collection
foreach ($site in $siteCollections) {
Write-Host “Processing site: $($site.Url)”
try {
# Create a batch delete job for versions older than 365 days
New-PnPSiteFileVersionBatchDeleteJob -SiteUrl $site.Url -LastRetainedVersionDate 365 -confirm:$false
Write-Host “Batch delete job created for site: $($site.Url)”
}
catch {
Write-Host “Error creating batch delete job for site: $($site.Url)”
Write-Host $_.Exception.Message
}
}
# Disconnect from SharePoint Online
Disconnect-PnPOnline
How This Script Works
Connect to SharePoint Online: The script first connects to your SharePoint Online tenant using the Admin Center URL.
Retrieve All Site Collections: It retrieves all site collections using the Get-SPOSite cmdlet.
Set Retention Date: The script calculates the retention date as 365 days before the current date.
Create Batch Delete Job: The New-SPOSiteFileVersionBatchDeleteJob cmdlet creates a batch job to delete versions older the days you’ve set.
Error Handling: If an error occurs, it logs the error and continues to the next site collection.
Best Practices for Intelligent Versioning and Cleanup
Define a Versioning Policy: Decide how many versions you want to retain for different types of documents. This can be configured in library settings or using PowerShell (e.g., -MajorVersionLimit X). I recommend having it in automatic!
Automate Version Cleanup: Use automation to regularly clean up old versions, minimizing the need for manual intervention.
Monitor Storage Usage: Regularly review storage reports from the SharePoint Admin Center to identify areas where storage is being consumed excessively. Make use of SharePoint Archive and Backup for data that isn’t needed on regular basis
Combine with Retention Policies: Protect critical files by applying Retention Labels or Retention Policies to ensure they are not deleted prematurely, especially for legal or compliance reasons.
Conclusion
As your organization grows, efficiently managing your SharePoint Online storage is crucial. Intelligent Versioning helps you retain the benefits of version control while optimizing storage and keeping costs under control.
By using PowerShell to automate version cleanup, you can streamline the process, ensuring that unnecessary versions are deleted without impacting important datam This way you can clean up old data and know that your future data isn’t being eaten up!
https://yourmodernworkplace.com/blog/Free-Storage-In-SharePoint-Online-Using-Intelligent-Versioning
So I’ve gotten more and more questions from users and client how to free up storage in their enviroment and I didn’t see and good post about how to do it, so I wrote a blogppost 🙂
Introduction
Freeing Storage in SharePoint Online Using Intelligent Versioning and PowerShell Automation
As organizations increasingly adopt SharePoint Online for collaboration and document management, managing storage efficiently becomes a critical challenge. One significant contributor to storage consumption is SharePoint’s versioning feature, which creates multiple versions of documents, leading to storage bloat over time.
In this post, we’ll discuss how to intelligently manage file versioning in SharePoint Online and automate the cleanup of old versions using PowerShell. By the end, you’ll have a clear strategy for maintaining healthy storage and managing SharePoint’s powerful versioning features effectively.
Understanding SharePoint Online Versioning
Versioning in SharePoint Online allows users to save multiple copies of documents as they get revised. This is essential for tracking changes, restoring earlier versions, and enabling collaboration. However, if not managed properly, the version history of documents can accumulate rapidly, consuming valuable storage space.
By default, SharePoint retains all versions of a document. Over time, this can lead to excessive storage usage, increased costs, and slower performance. This is where Intelligent Versioning becomes a useful strategy.
What is Intelligent Versioning?
Intelligent Versioning refers to a smart strategy that helps balance retaining valuable document history while freeing up unnecessary storage. Rather than keeping all document versions indefinitely, Intelligent Versioning helps ensure that only recent and important versions are retained, while older versions are deleted to conserve space.
This approach helps you optimize your SharePoint storage while preserving important data.
How Intelligent Versioning Works
Intelligent Versioning introduces a feature called automatic version thinning, which gradually trims older document versions while preserving key timestamps. Here’s how it works:
First 30 Days: All versions are kept.
From 30 to 180 Days: Hourly or daily versions are stored.
Beyond 180 Days: Weekly versions are kept indefinitely.
By using this automatic thinning approach, Microsoft reports that you can reduce version storage usage by up to 96% in some cases, without compromising users’ ability to access important historical versions.
My personal experience, I’ve seen storage saved 30-60% from various clients!
Benefits of Intelligent Versioning
Optimize Storage Costs: By deleting outdated versions, you reduce storage consumption, keeping within limits and potentially lowering costs.
Improve Performance: With fewer document versions stored, searches and retrieval times are faster.
Maintain Data Integrity: Intelligent Versioning ensures you delete only unnecessary versions while keeping critical ones intact.
How to Enable Intelligent Versioning
To enable Intelligent Versioning across your SharePoint Online tenant, use the following PowerShell command:
# Connect to SharePoint Online
$adminSiteUrl = “https://<tenant>-admin.sharepoint.com”
Connect-SPOService -Url $adminSiteUrl
# Enable Intelligent versioning
Set-SPOTenant -EnableVersionExpirationSetting $true
PnP Powershell:
# Install and Import PnP PowerShell module if not installed
# Install-Module -Name “PnP.PowerShell”
# Connect to SharePoint Online Admin Center
$adminSiteUrl = “https://<tenant>-admin.sharepoint.com”
Connect-PnPOnline -Url $adminSiteUrl -Interactive
# Enable Intelligent Versioning
Set-PnPTenant -EnableVersionExpirationSetting $true
Once enabled, this will apply Intelligent Versioning to all new files in SharePoint document libraries. You can verify this setting in the Admin Center under Versioning Settings.
Automating Version Cleanup Using PowerShell
While Intelligent Versioning applies to new documents, older files require manual intervention. Managing versions manually across multiple sites can be a tedious task. Fortunately, PowerShell allows you to automate the process.
Using the New-SPOSiteFileVersionBatchDeleteJob cmdlet, you can create batch deletion jobs to remove document versions older than a specified date.
Prerequisites:
SharePoint Online Administrator permissions.
SharePoint Online Management Shell installed.
PowerShell Script: Automating Version Cleanup
Here’s a PowerShell script that retrieves all site collections in your SharePoint Online tenant and creates a batch delete job for document versions older than 365 days:
# Connect to SharePoint Online
$adminSiteUrl = “https://<tenant>-admin.sharepoint.com”
Connect-SPOService -Url $adminSiteUrl
# Get all site collections
$siteCollections = Get-SPOSite -Limit All
# Loop through each site collection
foreach ($site in $siteCollections) {
Write-Host “Processing site: $($site.Url)”
# Create a batch delete job for versions older than 365 days
try {
New-SPOSiteFileVersionBatchDeleteJob -Identity $site.Url -DeleteBeforeDays 365 -confirm:$false
Write-Host “Batch delete job created for site: $($site.Url)”
}
catch {
Write-Host “Error creating batch delete job for site: $($site.Url)”
Write-Host $_.Exception.Message
}
}
# Disconnect from SharePoint Online
Disconnect-SPOService
PnP Powershell:
# Install the PnP PowerShell module if not already installed
# Install-Module -Name “PnP.PowerShell”
# Connect to SharePoint Online
$adminSiteUrl = “https://<tenant>-admin.sharepoint.com”
Connect-PnPOnline -Url $adminSiteUrl -Interactive
# Get all site collections
$siteCollections = Get-PnPTenantSite -IncludeOneDriveSites -Limit All
# Loop through each site collection
foreach ($site in $siteCollections) {
Write-Host “Processing site: $($site.Url)”
try {
# Create a batch delete job for versions older than 365 days
New-PnPSiteFileVersionBatchDeleteJob -SiteUrl $site.Url -LastRetainedVersionDate 365 -confirm:$false
Write-Host “Batch delete job created for site: $($site.Url)”
}
catch {
Write-Host “Error creating batch delete job for site: $($site.Url)”
Write-Host $_.Exception.Message
}
}
# Disconnect from SharePoint Online
Disconnect-PnPOnline
How This Script Works
Connect to SharePoint Online: The script first connects to your SharePoint Online tenant using the Admin Center URL.
Retrieve All Site Collections: It retrieves all site collections using the Get-SPOSite cmdlet.
Set Retention Date: The script calculates the retention date as 365 days before the current date.
Create Batch Delete Job: The New-SPOSiteFileVersionBatchDeleteJob cmdlet creates a batch job to delete versions older the days you’ve set.
Error Handling: If an error occurs, it logs the error and continues to the next site collection.
Best Practices for Intelligent Versioning and Cleanup
Define a Versioning Policy: Decide how many versions you want to retain for different types of documents. This can be configured in library settings or using PowerShell (e.g., -MajorVersionLimit X). I recommend having it in automatic!
Automate Version Cleanup: Use automation to regularly clean up old versions, minimizing the need for manual intervention.
Monitor Storage Usage: Regularly review storage reports from the SharePoint Admin Center to identify areas where storage is being consumed excessively. Make use of SharePoint Archive and Backup for data that isn’t needed on regular basis
Combine with Retention Policies: Protect critical files by applying Retention Labels or Retention Policies to ensure they are not deleted prematurely, especially for legal or compliance reasons.
Conclusion
As your organization grows, efficiently managing your SharePoint Online storage is crucial. Intelligent Versioning helps you retain the benefits of version control while optimizing storage and keeping costs under control.
By using PowerShell to automate version cleanup, you can streamline the process, ensuring that unnecessary versions are deleted without impacting important datam This way you can clean up old data and know that your future data isn’t being eaten up!
https://yourmodernworkplace.com/blog/Free-Storage-In-SharePoint-Online-Using-Intelligent-Versioning Read More