Skip to content

Instantly share code, notes, and snippets.

@jonimattila
Last active May 25, 2018 05:40
Show Gist options
  • Save jonimattila/a180eb7c030c63c9e66210f47375fc29 to your computer and use it in GitHub Desktop.
Save jonimattila/a180eb7c030c63c9e66210f47375fc29 to your computer and use it in GitHub Desktop.
Windows 10 automatic disk cleanup if windows temp folders older than 10 hours
if( ( (test-path 'C:\windows.old','C:\$WINDOWS.~BT','C:\$Windows.~WS') -eq $true).Count -and (test-path 'C:\windows.old','C:\$WINDOWS.~BT','C:\$Windows.~WS' -OlderThan (Get-Date).AddHours(-10) )){
& cscript /nologo "$dirfiles\AutomatedDiskCleanup.vbs"
}
If (Test-Path -LiteralPath 'C:\$WINDOWS.~BT') {
Remove-Item 'C:\$WINDOWS.~BT' -Recurse -Force
Write-Log -Message 'C:\$WINDOWS.~BT deleted' -Source $deployAppScriptFriendlyName
}
If (Test-Path -LiteralPath 'C:\$Windows.~WS') {
Remove-Item 'C:\$Windows.~WS' -Recurse -Force
Write-Log -Message 'C:\$Windows.~WS deleted' -Source $deployAppScriptFriendlyName
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment