0
我有一個簡單的PowerShell腳本來查找目錄中的最新文件,但我無法檢查文件大小是否大於0 MB。我已經發布我的腳本如下:PowerShell腳本查找最新文件並檢查其大小
$olddate = [DateTime]::MaxValue
$newdate = [DateTime]::MinValue
$oldfn = ""
$newfn = ""
$path = "U:\PGCLUSTER_BACKUP"
get-childitem $path | ForEach-Object {
if ($_.LastWriteTime -lt $olddate -and -not $_.PSIsContainer) {
$oldfn = $_.Name
$olddate = $_.LastWriteTime
}
if ($_.LastWriteTime -gt $newdate -and -not $_.PSIsContainer) {
$newfn = $_.Name
$newdate = $_.LastWriteTime
}
}
$output = ""
if ($newfn -ne "") { $output += "`nNewest: " + $newdate + " -- " + $newfn }
if ($output -eq "") { $output += "`nFolder is empty." }
$output + "`n"
請給我一些建議,我可以做些什麼來解決這個問題。