New
#31
Doesn't work, get the same result with or without Sort-Object.
There's a way to regroup the services as per the tutorial below from the Winaero site
Set Split Threshold for Svchost in Windows 10 - Winaero
That is because the |sort-object is within the foreach loop. So each time it is sorting 1 thing.
It is saying for every process (sorted by Id ), I'm going to find its name using Get-WmiObject. Then I'll sort that (one specific) DispayName.
Obviously the results will be the same as you are still sorting by Id even though you have then further sorted the DispayName for the Id (which is unique anyway).
Another method is to put all the results from the foreach loop into another array (for example $names).
This appears slower because rather than writing out one line at a time to the console it does them all. It isn't slower btw just doesn't keep you updated.
You can then sort $names by DisplayName rather than Id as it then has the information it wants to sort by.
Or indeed output $names with or without sorting toOut-GridView and sort using the GUI.
I've been idly thinking about it but haven't come up with a more elegant solution. More of a StackOverflow question though really...
Last edited by lx07; 13 Apr 2017 at 05:44.