Last active
May 25, 2018 05:40
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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