Skip to content

Instantly share code, notes, and snippets.

@muratvezir
Last active February 21, 2024 13:38
Show Gist options
  • Save muratvezir/0701817a7187be537f6bd3e8ee8d7894 to your computer and use it in GitHub Desktop.
Save muratvezir/0701817a7187be537f6bd3e8ee8d7894 to your computer and use it in GitHub Desktop.
File Server Maintanence
# 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."
}
}
@muratvezir
Copy link
Author

İnitial

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment