Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $TranscriptFile = ".\$(Get-Date -Format "yyyy_MM_dd")_Transcript.log"
- Start-Transcript $TranscriptFile
- $Roots = @(".\Office\Data"<# Extra locations for C2R downloads can go here.#>)
- ForEach($Root in $Roots)
- {
- Set-Location $Root
- Write-Output "Checking $Root..."
- $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)
- # If any old stream contents folders were found, remove them.
- $OldStreams = Get-ChildItem -Path $Root | Where Name -like "16.*" | Where Name -notlike "*$Max*"
- If($OldStreams)
- {
- Write-Output "Deleting $OldStreams"
- Remove-Item -Path $OldStreams -Recurse -Confirm:$false
- }
- # If any old .cab's were found, remove them.
- $OldCabs = Get-ChildItem -Path $Root | Where Name -like "v32_*.cab" | Where Name -notlike "*$Max*"
- If($OldCabs)
- {
- Write-Output "Deleting $OldCabs"
- Remove-Item -Path $OldCabs -Confirm:$false
- }
- }
- Stop-Transcript
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement