Advertisement
Guest User

Untitled

a guest
Oct 21st, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. $TranscriptFile = ".\$(Get-Date -Format "yyyy_MM_dd")_Transcript.log"
  2. Start-Transcript $TranscriptFile
  3.  
  4. $Roots = @(".\Office\Data"<# Extra locations for C2R downloads can go here.#>)
  5.  
  6. ForEach($Root in $Roots)
  7. {
  8. Set-Location $Root
  9.  
  10. Write-Output "Checking $Root..."
  11. $Max = [Math]::round((Get-ChildItem -Path $Root | Where Name -like 16.* | Select -exp name | % { [float]($_ -replace "16\.0\.","") } | Measure-Object -Maximum | Select -exp Maximum), 2)
  12.  
  13. # If any old stream contents folders were found, remove them.
  14. $OldStreams = Get-ChildItem -Path $Root | Where Name -like "16.*" | Where Name -notlike "*$Max*"
  15. If($OldStreams)
  16. {
  17. Write-Output "Deleting $OldStreams"
  18. Remove-Item -Path $OldStreams -Recurse -Confirm:$false
  19. }
  20.  
  21. # If any old .cab's were found, remove them.
  22. $OldCabs = Get-ChildItem -Path $Root | Where Name -like "v32_*.cab" | Where Name -notlike "*$Max*"
  23. If($OldCabs)
  24. {
  25. Write-Output "Deleting $OldCabs"
  26. Remove-Item -Path $OldCabs -Confirm:$false
  27. }
  28. }
  29.  
  30. Stop-Transcript
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement