Page 4 of 4 FirstFirst ... 234
  1.    11 Apr 2017 #31
    Join Date : Apr 2014
    Space coast of Florida
    Posts : 5,343
    Windows 10 Pro X64 16299.19

    Doesn't work, get the same result with or without Sort-Object.
      My ComputersSystem Spec
  2.    11 Apr 2017 #32
    Join Date : Aug 2015
    Melbourne
    Posts : 225
    Win 10 Pro X64

    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
      My ComputerSystem Spec
  3.    12 Apr 2017 #33
    Join Date : Apr 2016
    Italy
    Posts : 91
    Windows 10 Pro
    Thread Starter

    Quote Originally Posted by Ztruker View Post
    Doesn't work, get the same result with or without Sort-Object.
    It's strange but this works for me:

    $array=get-process |where-object {$_.ProcessName -Match "svchost"}|Select Id
    $names=foreach($item in $array.Id){
    Get-WmiObject -Class win32_service -Filter "ProcessID='$item'" | select DisplayName
    }
    $names | sort-object DisplayName
      My ComputerSystem Spec
  4.    12 Apr 2017 #34
    Join Date : Apr 2014
    Space coast of Florida
    Posts : 5,343
    Windows 10 Pro X64 16299.19

    Quote Originally Posted by JoeMcLutz View Post
    It's strange but this works for me:

    $array=get-process |where-object {$_.ProcessName -Match "svchost"}|Select Id
    $names=foreach($item in $array.Id){
    Get-WmiObject -Class win32_service -Filter "ProcessID='$item'" | select DisplayName
    }
    $names | sort-object DisplayName
    Yes, that works perfectly for me as well, many thanks.
      My ComputersSystem Spec
  5.    13 Apr 2017 #35
    Join Date : Apr 2016
    Italy
    Posts : 91
    Windows 10 Pro
    Thread Starter

    Quote Originally Posted by Ztruker View Post
    Yes, that works perfectly for me as well, many thanks.
    Ooh! Fine! You're welcome: I'm happy for you!
      My ComputerSystem Spec
  6.    13 Apr 2017 #36
    Join Date : Jul 2015
    Posts : 3,694
    10 Pro

    Quote Originally Posted by Ztruker View Post
    Doesn't work, get the same result with or without Sort-Object.
    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.
      My ComputerSystem Spec
  7.    13 Apr 2017 #37
    Join Date : Apr 2014
    Space coast of Florida
    Posts : 5,343
    Windows 10 Pro X64 16299.19

    Quote Originally Posted by lx07 View Post
    Or indeed output $names with or without sorting to Out-GridView and sort using the GUI.
    Using the GUI to sort is a nice idea. Works well too. Thank you.
      My ComputersSystem Spec

 
Page 4 of 4 FirstFirst ... 234


Similar Threads
Thread Forum
Solved Windows Update with Metered connection fails: Creators Update 15063.0
It's dejŠ vu all over again. :doh: The correct behaviour of windows update over a metered connection is to offer the choice to download, or wait until on a non-metered connection. 128460 The initial build of the Anniversary Update broke...
Windows Updates and Activation
Windows 10 Creators Update available through the Update Assistant
:arrow: Windows 10 Creators Update version 1703 (build 15063) now available from Windows 10 Update Assistant. See also: Managing Windows 10 Creators Update rollout for a seamless experience - - Windows 10 Forums Windows 10 Creators Update...
Windows 10 News
Windows 10 Creators Update and Creators Update SDK are Released
Source: Windows 10 Creators Update and Creators Update SDK are Released - Building Apps for WindowsBuilding Apps for Windows :arrow: Windows 10 Creators Update version 1703 (build 15063) now available from Windows 10 Update Assistant. ...
Windows 10 News
Visual Studio 2017 Update Preview and Windows 10 Creators Update SDK
Source: https://blogs.msdn.microsoft.com/visualstudio/2017/03/16/visual-studio-2017-update-preview-and-windows-10-creators-update-sdk/
Windows 10 News
Creators Update: Will I be able to chose the time of actual update.
I notice that many updates occur automatically. With small updates I don't even know they have occurred. I always try to make a restore point before a big update actually updates my comp. (for obvious reasons) and I am sometime given notice, often...
Windows Updates and Activation
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 23:24.
Find Us
Twitter Facebook Google+ Ten Forums iOS App Ten Forums Android App



Windows 10 Forums