0
votes
$out = Get-WmiObject -class Win32_PerfFormattedData_Tcpip_NetworkInterface |
    select name , BytesTotalPersec

$out.popup("Network status",0,"Done",0x1)

Error : Method invocation failed because [Selected.System.Management.ManagementObject] does not contain a method named 'popup'. At line:2 char:1 + $out.popup("Network status",0,"Done",0x1) + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~     + CategoryInfo          : InvalidOperation: (popup:String) [], RuntimeException     + FullyQualifiedErrorId : MethodNotFound

2
Like the error says, that object doesn't have a popup method.js2010
Allow me to give you the standard advice to newcomers: If an answer solves your problem, please accept it by clicking the large check mark (✓) next to it and optionally also up-vote it (up-voting requires at least 15 reputation points). If you found other answers helpful, up-vote them. Accepting (for which you'll gain 2 reputation points) and up-voting help future readers. See this article for more information. If your question isn't fully answered yet, please provide feedback or self-answer.mklement0

2 Answers

4
votes
using assembly System.Windows.Forms
using namespace System.Windows.Forms
[messagebox]::show('hello world')
2
votes

PopUp is a method called from the Wscript.Shell class. It won't work from a WMI instance object (or collection of instances). If you wanted to display the results of that WMI query using the pop-up style message box from your example you would have to do something like this.

$out = Get-WmiObject -class Win32_PerfFormattedData_Tcpip_NetworkInterface | select name , BytesTotalPersec | Out-String

$wshell = New-Object -ComObject Wscript.Shell
$wshell.Popup("Network Status:`n $out",0,"Done",0x1)

Or you can simplify it a bit by just piping the data to a gridview.

Get-WmiObject -class Win32_PerfFormattedData_Tcpip_NetworkInterface | select name , BytesTotalPersec | Out-GridView

Hope that helps.