Answered by:
I would like to display output in real time!!!

Question
-
while(1){ Get-WmiObject -class Win32_PerfFormattedData_Tcpip_NetworkInterface |select name , BytesTotalPersec | Out-File -FilePath "c:\vm\value.txt" $out = Get-Content -Path "C:\temp\vm\value.txt" } $out | Out-GridView
I am trying to display the out value in real time in a popup. Above mentioned code doesn't bring any error , but I believe it is stuck in loop. It doesn't display the Grid popup with output. Any ideas would be appreciated!Sunday, June 23, 2019 3:07 PM
Answers
-
& {
while(1){
Get-WmiObject Win32_PerfFormattedData_Tcpip_NetworkInterface |
select name, BytesTotalPersec
sleep 1
}
} | out-gridview
While doesn't stream, but a scriptblock with a call operator does (or a function).
- Marked as answer by AgaciAvinas Wednesday, June 26, 2019 5:12 PM
- Edited by JS2010 Thursday, June 27, 2019 1:33 PM
Monday, June 24, 2019 8:00 PM
All replies
-
What do you mean by "real time". PowerShell is not a "real time" system.
Do you mean you want to open in the pipeline?
This is as close as you will get.
1..100 | ForEach-Object { Get-WmiObject Win32_PerfFormattedData_Tcpip_NetworkInterface } | Select-Object name, BytesTotalPersec | Out-GridView
\_(ツ)_/
Sunday, June 23, 2019 4:21 PM -
You can do this in the console:
get-content -wait C:\temp\vm\value.txt
- Edited by JS2010 Sunday, June 23, 2019 4:37 PM
Sunday, June 23, 2019 4:36 PM -
If you use Get-Counter it can display at defined intervals. There are also other system utilities that can track network TX/RX numbers ina GUI.
"PerfMon" is about the best diagnostic and performance monitoring tool available on WIndows.
At any prompt type "perfmon" and select the menu item "Perfomance Monitoring".
This is a GUI that display exactly what you are trying to display and it is updated dynamically on any interval you choose.
See this for complete instructions from MS, https://techcommunity.microsoft.com/t5/Ask-The-Performance-Team/Windows-Performance-Monitor-Overview/ba-p/375481
\_(ツ)_/
Sunday, June 23, 2019 5:23 PM -
How about this?
While ($true){ Get-WmiObject -class Win32_PerfFormattedData_Tcpip_NetworkInterface |select name , BytesTotalPersec | convertto-html -Head '<title>HTML TABLE</title><META HTTP-EQUIV="refresh" CONTENT="1">'| Out-File c:\temp\test.html
Sleep 0.9 # or whatever you think is appropriate -- or just omit it altogether }
Launch a browser and open the HTML file. It'll refresh once every second.--- Rich Matheisen MCSE&I, Exchange Ex-MVP (16 years)
Sunday, June 23, 2019 6:04 PM -
& {
while(1){
Get-WmiObject Win32_PerfFormattedData_Tcpip_NetworkInterface |
select name, BytesTotalPersec
sleep 1
}
} | out-gridview
While doesn't stream, but a scriptblock with a call operator does (or a function).
- Marked as answer by AgaciAvinas Wednesday, June 26, 2019 5:12 PM
- Edited by JS2010 Thursday, June 27, 2019 1:33 PM
Monday, June 24, 2019 8:00 PM -
This is the closest. Thank you!Wednesday, June 26, 2019 5:12 PM