Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Path for CSV. Headers in CSV are "Site" and "Prosjektnavn"(Means project name in Norwegian)
- $csvPath = "C:\Temp\SharepointAutomaticTrimming.csv"
- #CSV-file import to PS
- $sites = Import-Csv -Path $csvPath
- Start-Transcript
- #Goes through every SharePoint Site to start trimjob for given sites in CSV.
- Foreach ($site in $sites) {
- $siteurl = $site.sites
- $sitename = $site.prosjektnavn
- Try {
- Write-host "Starting trimjob on: $siteurl" -ForegroundColor white -BackgroundColor DarkCyan
- New-SPOSiteFileVersionBatchDeleteJob -Identity $siteurl -Automatic -Confirm:$false
- write-host "Trimjob has begun for $siteurl | It can take days before the trimjob completes" -ForegroundColor white -BackgroundColor green
- } Catch {
- Write-host "Could not start trimjon for: $siteurl. Error: $_" -foregroundcolor red -backgroundcolor white
- }
- }
- Stop-Transcript
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement