码迷,mamicode.com
首页 > 系统相关 > 详细

powershell 获取过期的文件

时间:2015-05-12 19:08:50      阅读:166      评论:0      收藏:0      [点我收藏+]

标签:documents   folder   function   hello   yellow   


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


powershell 获取过期的文件

标签:documents   folder   function   hello   yellow   

原文地址:http://3544640.blog.51cto.com/3534640/1650651

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!