wlzxwfk 发表于 2018-9-2 11:58:44

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

页: [1]
查看完整版本: powershell 获取过期的文件