Advertisement
Guest User

SharePoint Version History Trimming - Powershell Script

a guest
Jan 15th, 2025
283
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PowerShell 0.85 KB | Source Code | 0 0
  1. #Path for CSV. Headers in CSV are "Site" and "Prosjektnavn"(Means project name in Norwegian)
  2. $csvPath = "C:\Temp\SharepointAutomaticTrimming.csv"
  3.  
  4. #CSV-file import to PS
  5. $sites = Import-Csv -Path $csvPath
  6.  
  7.  
  8.  
  9. Start-Transcript
  10. #Goes through every SharePoint Site to start trimjob for given sites in CSV.
  11. Foreach ($site in $sites) {
  12.     $siteurl = $site.sites
  13.     $sitename = $site.prosjektnavn
  14.     Try {
  15.         Write-host "Starting trimjob on: $siteurl" -ForegroundColor white -BackgroundColor DarkCyan
  16.         New-SPOSiteFileVersionBatchDeleteJob -Identity $siteurl -Automatic -Confirm:$false
  17.         write-host "Trimjob has begun for $siteurl | It can take days before the trimjob completes" -ForegroundColor white -BackgroundColor green
  18.     } Catch {
  19.         Write-host "Could not start trimjon for: $siteurl. Error: $_" -foregroundcolor red -backgroundcolor white
  20.     }
  21. }
  22. Stop-Transcript
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement