Files
Sandbox/VMware-OrphanedFilesOnDatastore.ps1
Zack Meier 03dba08135 sync
2026-04-15 15:42:41 -05:00

19 lines
680 B
PowerShell

# datastore
$AllDatastores = Get-Datastore -Name *FS92* | sort-object Name
$AllFiles = @()
ForEach ($Datastore in $AllDatastores) {
write-warning $Datastore.name
Set-Location $Datastore.DatastoreBrowserPath
$expiredFolders = Get-ChildItem | `
Where-Object { $_.Name -notlike "*.sf" -and $_.Name -notlike ".vSphere*" -and $_.Name -notlike ".dvs*" -and $_.Name -notlike ".naa*" -and $_.Name -ne 'vmkdump' -and $_.Name -ne 'syslog'} | `
Where-Object LastWriteTime -LT ((Get-Date).AddDays(-30))
ForEach ($folder in $expiredFolders) {
write-warning $folder.name
$AllFiles += Get-ChildItem -Path $Folder.FullName -Recurse
}
}