Last active
February 21, 2024 13:38
-
-
Save muratvezir/0701817a7187be537f6bd3e8ee8d7894 to your computer and use it in GitHub Desktop.
File Server Maintanence
This file contains hidden or 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
# Which Folder we are looking in to it | |
$folderPath = "C:\Path\To\Your\Folder" | |
$oneMBF = (Get-Date).AddMonths(-1) | |
# Recurse On the folders | |
Get-ChildItem -Path $folderPath -Directory | ForEach-Object { | |
$folderName = $_.Name | |
$folderCreateDate = $_.CreationTime | |
# Do not delete topology an chk folder | |
if ($folderName -ne "topology.xml" -and $folderName -ne "chk") { | |
# Klasör eski mi kontrol et | |
if ($folderCreateDate -lt $oneMBF) { | |
# Eğer eskiyse, sil | |
#Remove-Item -Path $_.FullName -Recurse -Force | |
Write-Host "$folderName folder deleted." | |
} | |
} | |
else { | |
Write-Host "Topology and chk Folder skipped." | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
İnitial