powershell 獲取過期的文件


function funline($strin="hello")

{

    $num=$strin.length

    for($i=1;$i -le $num;$i++){$funline = $funline + "="}

        Write-Host -ForegroundColor Yellow $strin

        Write-Host -ForegroundColor DarkRed $funline

   }


$folder="C:\Users\qliangliang.BOOK\Documents"

$date=get-date

$limit=3

$xfiles=$Null

Get-ChildItem -Path $folder -Force | ForEach-Object {

    $newdate=($_.LastAccessTime).AddDays($limit)

    $limitDate=New-TimeSpan -Start $date -End $newdate

    if($limitDate -le 0)

    {

        $xfiles+=@{$_.Name=$_.LastAccessTime}

    }

}

funline("the expired files art listed below")

$xfiles


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章