Powershell 展示数据处理进度, 并已进度条展示
$userlist = @() $users = gc D:\Script\ImportFiles\accountslist.txt $i = 0 foreach($user in $users) { $i++ $w = $i.ToString() + '/' + $users.Count.ToString() $percent = "{0:0.0%}" -f ($i/$users.Count) Write-Progress -Activity "Preparation 进度显示" -Status "请耐心等待,$w , $percent" -PercentComplete ($i/($users.count) * 100) try { Get-Mailbox $mail -WarningAction SilentlyContinue -ErrorAction Stop |Out-Null $obj = New-Object psobject $obj |Add-Member -MemberType NoteProperty -Name EmailFound -Value 'True' -Force $userlist += $obj } catch { $obj01 = New-Object psobject $obj01 |Add-Member -MemberType NoteProperty -Name EmailFound -Value 'False' -Force $userlist += $obj01 } } $userlist |ogv
结果展示