Invole-command doesn't output when using mainwindowtitle for gps

I am writing a script which will give the count of process running based on the window title, remotely from multuple machine. However i am not getting the out put displayed with the consoles name. Does get-process output the mainwindowstitle property when invoced through invoke-command?

Please find reference to script:

Below is the output that i get:

Count Name PSComputerName
36 machine01
33 machine02
This is the output that i am looking at:
Count Name PSComputerName
8 internalHigh telxkcbilling02
7 internalHigh telxkcbilling01
Hi Parth Gandhi, please share the code which you have modified.

We suggest pasting code in gist and share the link here than pastebin the forum has the capability to display the code from gist directly in to the post.

For your question, Mainwindowstitle cannot be selected from Group-Object cmdlet output. The output is grouped inside the scriptblock. You can create a calculated property to do this.

... | Select-Object Count,Name,@{E={$_.Group.mainWindowtitle};L='mainWindowtitle'}

Hi Parth,

There is no need to use Invoke-Command when running Get-Process. There is a -ComputerName parameter you can use to query processes on remote computers. Also, a couple of things about the script.

  1. Turn the “From”, “To”, and “SmtpServer” variables into parameters, that will make it easier when the next person runs it or if you need to change values.
  2. Try to avoid using the back tick. You can go to the next line after a | character.
    Get-Process |
    Select-Object Name, Cpu
  3. Try to avoid using aliases. Think of the next person that may use your script or modify it. 6 months down the road, you may think, what it is I was trying to do here?

When calling Group-Object and grouping Name, you are losing the other properties from the Get-Process Cmdlet. Try just running Get-Process -ComputerName server1 |Where-Object {$_.MainWindowTitle -like ‘high’} |Group-Object Name and view the output.

Also, when filtering the process, try to be more specific, there may be other processes with “high” and could cause problems in your output.

Hope that helps.