运行流程时的Powershell可见进度

时间:2017-09-28 15:15:51

标签: powershell progress

我完成了我的powershell脚本,它完美地完成了应该做的事情。但对于脚本的使用它有点乱。对于我身边的真实测试来说,这是完美的,但现在他们所需要的只是看到了这一点。

我有一些想法并且已经看到很多选择,但我无法获得一些工作。

在我看来,最好的情况是他们能看到进步和背后发生的事情。 到目前为止,我最好的解决方案就是这个。

#$i++
#$intLength = rows in csv     I don't know how to get this 
#Write-Host "Processing ..."
#Write-Host " $i done of $intLength"

所以这应该在powershell的顶部,而在下面应该通过

foreach($n in $y)
{ 
    try 
        {
        $Computer = [system.net.dns]::resolve($n.$Filter) | Select HostName,AddressList
        $IP = ($Computer.AddressList).IPAddressToString
        Write-Host $n.$Filter $IP
        New-Object PSObject -Property @{IPAddress=$IP; $colname=$n.$Filter} | Export-Csv $Saveworking -NoTypeInformation -Append
        } 
    catch 
        {
        Write-Host "$($n.$Filter) is unreachable."
        New-Object PSObject -Property @{$colname=$n.$Filter} | Export-Csv $SaveFailed -NoTypeInformation -Append
        }
}

有没有办法优先考虑"所以从上面来看这很好,即使有大约600条线路正在运行,也看到了整个进度?

如果需要,我也可以移交完整的脚本进行复制。

先谢谢你

0 个答案:

没有答案