#------------------------------------------------------------------------# # Script excludes Temp and WindowApps folder from file-level backup # # plans # # # # Created by Alex V # # 09/07/2019 # # # # All rights reserved :) # #------------------------------------------------------------------------# $Exclusions = '%USERPROFILE%\AppData\Local\Microsoft\WindowsApps', '%USERPROFILE%\AppData\Local\Packages', '%USERPROFILE%\AppData\Local\Temp' foreach ($_ in (Get-ChildItem ("$env:ProgramData\Online Backup") -Filter "*.cbb" -ErrorAction SilentlyContinue)) { $BackupPlan = [xml](Get-Content ($xmlPath = $_.FullName)) if ($BackupPlan.BasePlan.type -eq "Plan"){ Write-Host "Adding exclusions to plan:" $BackupPlan.BasePlan.Name -ForegroundColor Green foreach($exclusion in $Exclusions){ $element = ((($BackupPlan.BasePlan.SelectSingleNode("//ExcludedItems")).AppendChild($BackupPlan.CreateElement("PlanItem"))).AppendChild($BackupPlan.CreateElement("Path"))).AppendChild($BackupPlan.CreateTextNode($exclusion)) $BackupPlan.Save($xmlPath) } } }