Powershell控制台告诉主机它还活着

时间:2014-10-17 13:42:27

标签: powershell

我正在使用GCI -ecurse搜索孔硬盘,之后我正在使用结果... 我该怎么办,让控制台告诉我它还活着? 像GCI C:\ -recurse blabla .... |每2分钟写主持人"我还在搜索"

编辑:

$File = Get-ChildItem $Path -Recurse -ErrorAction SilentlyContinue
| where {$_.PsIsContainer -eq $false -and $_.CreationTime -le "$OldDate"} 
| select -Property name,Fullname 
| write-progress -activity "Searching..." -Status "Please wait..." -percentcomplete ???

$ Path有很多文件和文件夹,需要几天才能完成这项任务 如何计算完成百分比?如果我使用计数,它会先计算所有项目吗?! 它也可以,如果计算文件继续如下:

if($countfiles -ge "10000")
{write-Host "Still working, currently $_"}
else {$countfiles=$countfiles+1}

2 个答案:

答案 0 :(得分:1)

这将写入状态的状态消息,并将子项传递给管道。写主机可以替换为您实际想要对子项进行的任何处理

get-childitem -recurse| %{write-progress -Status $_ -Activity "Trawling...";$_} | %{write-host $_}

答案 1 :(得分:0)

Get-ChildItem C:\ -recurse -verbose

或者我在问题中遗漏了什么?