{"id":17241,"date":"2010-09-02T00:01:00","date_gmt":"2010-09-02T00:01:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2010\/09\/02\/using-windows-powershell-to-determine-service-launch-order\/"},"modified":"2010-09-02T00:01:00","modified_gmt":"2010-09-02T00:01:00","slug":"using-windows-powershell-to-determine-service-launch-order","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/using-windows-powershell-to-determine-service-launch-order\/","title":{"rendered":"Using Windows PowerShell to Determine Service Launch Order"},"content":{"rendered":"<p><strong><\/strong><\/p>\n<p><strong>Summary<\/strong>: The Microsoft Scripting Guys show how to determine service launch order by using Windows PowerShell and WMI in this helpful step-by-step article.<\/p>\n<p>&nbsp;<\/p>\n<p><img decoding=\"async\" height=\"34\" width=\"34\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/q-for-powertip.jpg\" align=\"left\" alt=\"Hey, Scripting Guy! Question\" border=\"0\" title=\"Hey, Scripting Guy! Question\" \/> Hey, Scripting Guy! I need to find out the order in which services start on my computer. To properly shut down a computer, the services should stop in reverse order that they start. I can find service dependencies via the services.msc tool, but I cannot seem to find anywhere that tells me the actual order in which services start. Can you help me?<\/p>\n<p>&#8212; RY<\/p>\n<p><img decoding=\"async\" height=\"34\" width=\"34\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/a-for-powertip.jpg\" align=\"left\" alt=\"Hey, Scripting Guy! Answer\" border=\"0\" title=\"Hey, Scripting Guy! Answer\" \/><\/p>\n<p> Hello RY, <\/p>\n<p>Microsoft Scripting Guy Ed Wilson here. I was deep in thought working on a script to illustrate service load order when the <a href=\"http:\/\/en.wikipedia.org\/wiki\/Landline\">landline<\/a> rang. My landline almost never rings, and if it does, it is generally phone <a href=\"http:\/\/en.wikipedia.org\/wiki\/Spam_(electronic)\">spam<\/a>, which I ignore it. In fact, I do not even bother to look at the <a href=\"http:\/\/en.wikipedia.org\/wiki\/Caller_ID\">caller ID<\/a> because I know the call will not be of interest to me. If people want to talk to me, they call my Windows Mobile 6.5 phone, catch me on <a href=\"http:\/\/bit.ly\/scriptingguystwitter\">Twitter<\/a>, post something on Facebook, shoot me an email, or find me on Communicator. They do not call my landline. For me, the only reason I have a landline is so I can have <a href=\"http:\/\/en.wikipedia.org\/wiki\/Adsl\">ADSL<\/a>. Now, Teresa, that is a different story. <\/p>\n<p>Anyway, the call was from one of the organizers of the <a href=\"http:\/\/www.sqlsaturday.com\/46\/eventhome.aspx\">Raleigh, NC., SQL Saturday event<\/a>, and I will now be speaking there on September 18, 2010. I am excited about the event, not only because I get to speak, but also because there will be <a href=\"http:\/\/www.sqlsaturday.com\/46\/schedule.aspx\">some awesome sessions<\/a>. And all the cool people within the tri-state region will be there. I will be talking about <a href=\"http:\/\/support.microsoft.com\/kb\/968929\">Windows PowerShell 2.0<\/a> best practices, and I will pull together information from the Microsoft Press book, <a href=\"http:\/\/www.amazon.com\/Windows-PowerShell-2-0-Best-Practices\/dp\/0735626464\/ref=sr_1_1?ie=UTF8&amp;s=books&amp;qid=1255959455&amp;sr=8-1\">Windows PowerShell 2.0 Best Practices<\/a>, which I wrote. It will be very cool. By the way, Teresa will be there as well, and she is a lot more fun to talk to than I am. (<strong>Scripting Editor<\/strong>: They are both fun to talk to. Be sure to ask Ed about tea.)<\/p>\n<p>RY, once I got off the phone, I completed the Get-ServiceLoadOrder.ps1 script. The complete script is shown here. <\/p>\n<blockquote>\n<p><strong>Get-ServiceLoadOrder.ps1<\/strong><\/p>\n<p>Get-WmiObject -Class win32_LoadOrderGroupServiceMembers |     <br \/>ForEach-Object {      <br \/> New-Object -TypeName psobject -Property `      <br \/>&nbsp;&nbsp; @{      <br \/>&nbsp;&nbsp;&nbsp;&nbsp; &#8220;GroupOrder&#8221;=([wmi]$_.GroupComponent).GroupOrder      <br \/>&nbsp;&nbsp;&nbsp;&nbsp; &#8220;GroupName&#8221;=([wmi]$_.GroupComponent).Name      <br \/>&nbsp;&nbsp;&nbsp;&nbsp; &#8220;ServiceName&#8221;=([wmi]$_.PartComponent).Name      <br \/>&nbsp;&nbsp;&nbsp;&nbsp; &#8220;Started&#8221;=([wmi]$_.PartComponent).Started      <br \/>&nbsp;&nbsp;&nbsp; }      <br \/>} |       <br \/>Where-Object { $_.started } |       <br \/>Sort-Object -Property grouporder -Descending<\/p>\n<\/blockquote>\n<p>Services group load order is stored in the registry in the <strong>HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\ServiceGroupOrder<\/strong> registry key. This is shown in the following image.<\/p>\n<p><a href=\"https:\/\/docs.microsoft.com\/\"><img decoding=\"async\" height=\"345\" width=\"554\" src=\"https:\/\/docs.microsoft.com\/\" alt=\"Image of registry key in which services group load order is stored\" border=\"0\" title=\"Image of registry key in which services group load order is stored\" style=\"border-bottom: 0px;border-left: 0px;padding-left: 0px;padding-right: 0px;border-top: 0px;border-right: 0px;padding-top: 0px\" \/><\/a><\/p>\n<p>You do not have to directly query the registry key if you do not wish to do so, because WMI can retrieve the information by querying the <strong>win32_loadOrderGroup<\/strong> WMI class. Output from this class is shown in the following image.<\/p>\n<p><a href=\"https:\/\/docs.microsoft.com\/\"><img decoding=\"async\" height=\"423\" width=\"554\" src=\"https:\/\/docs.microsoft.com\/\" alt=\"Image of output from win32_loadOrderGroup WMI class\" border=\"0\" title=\"Image of output from win32_loadOrderGroup WMI class\" style=\"border-bottom: 0px;border-left: 0px;padding-left: 0px;padding-right: 0px;border-top: 0px;border-right: 0px;padding-top: 0px\" \/><\/a><\/p>\n<p>The Get-ServiceLoadOrder.ps1 script begins by using the <strong>Get-WmiObject<\/strong> cmdlet to query the <strong>Win32_LoadOrderGroupServiceMembers<\/strong> WMI class, which is an association class. Association classes relate one WMI class to another WMI class. The two classes that are related are the <strong>Win32_BaseService<\/strong> and the <strong>Win32_LoadOrderGroup<\/strong> class. This relationship is shown in the following image.<\/p>\n<p><a href=\"https:\/\/docs.microsoft.com\/\"><img decoding=\"async\" height=\"389\" width=\"554\" src=\"https:\/\/docs.microsoft.com\/\" alt=\"Image of relationship between Win32_BaseService class and Win32_LoadOrderGroup class\" border=\"0\" title=\"Image of relationship between Win32_BaseService class and Win32_LoadOrderGroup class\" style=\"border-bottom: 0px;border-left: 0px;padding-left: 0px;padding-right: 0px;border-top: 0px;border-right: 0px;padding-top: 0px\" \/><\/a><\/p>\n<p>When the <strong>Win32_LoadOrderGroupServiceMembers<\/strong> WMI class is queried, the information that is returned does not look too exciting. An example of the kind of information that is returned is shown here: <\/p>\n<blockquote>\n<p>PS C:\\&gt; Get-WmiObject -Class win32_LoadOrderGroupServiceMembers     <br \/>__GENUS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : 2      <br \/>__CLASS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : Win32_LoadOrderGroupServiceMembers      <br \/>__SUPERCLASS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : CIM_Component      <br \/>__DYNASTY&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : CIM_Component      <br \/>__RELPATH&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : Win32_LoadOrderGroupServiceMembers.GroupComponent=&#8221;\\\\\\\\MRED1\\\\roo      <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; t\\\\cimv2:Win32_LoadOrderGroup.Name=\\&#8221;Boot Bus Extender\\&#8221;&#8221;,PartCom      <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ponent=&#8221;\\\\\\\\MRED1\\\\root\\\\cimv2:Win32_SystemDriver.Name=\\&#8221;ACPI\\&#8221;&#8221;      <br \/>__PROPERTY_COUNT : 2      <br \/>__DERIVATION&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : {CIM_Component}      <br \/>__SERVER&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : MRED1      <br \/>__NAMESPACE&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : root\\cimv2      <br \/>__PATH&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : \\\\MRED1\\root\\cimv2:Win32_LoadOrderGroupServiceMembers.GroupCompon      <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ent=&#8221;\\\\\\\\MRED1\\\\root\\\\cimv2:Win32_LoadOrderGroup.Name=\\&#8221;Boot Bus      <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Extender\\&#8221;&#8221;,PartComponent=&#8221;\\\\\\\\MRED1\\\\root\\\\cimv2:Win32_SystemDri      <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ver.Name=\\&#8221;ACPI\\&#8221;&#8221;      <br \/>GroupComponent&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : \\\\MRED1\\root\\cimv2:Win32_LoadOrderGroup.Name=&#8221;Boot Bus Extender&#8221;      <br \/>PartComponent&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : \\\\MRED1\\root\\cimv2:Win32_SystemDriver.Name=&#8221;ACPI&#8221;<\/p>\n<\/blockquote>\n<p>The two main properties that are returned are called <strong>GroupComponent<\/strong> and <strong>PartComponent<\/strong>&mdash;they do not even sound too exciting. However, as seen in the following image, these two properties point to the key property of their respective classes. <\/p>\n<p><a href=\"https:\/\/docs.microsoft.com\/\"><img decoding=\"async\" height=\"389\" width=\"554\" src=\"https:\/\/docs.microsoft.com\/\" alt=\"Image of two main properties pointing to key property of respective classes\" border=\"0\" title=\"Image of two main properties pointing to key property of respective classes\" style=\"border-bottom: 0px;border-left: 0px;padding-left: 0px;padding-right: 0px;border-top: 0px;border-right: 0px;padding-top: 0px\" \/><\/a><\/p>\n<p>This is exciting! The reason is that the <strong>PartComponent<\/strong> and <strong>GroupComponent<\/strong> properties contain the path to a specific instance of a WMI class. Compare the <strong>__Path<\/strong> property from the query below with the value of the <strong>PartComponent<\/strong> property seen above. They are the same. <\/p>\n<blockquote>\n<p>PS C:\\&gt; gwmi win32_baseservice -Filter &#8220;name = &#8216;acpi'&#8221; | fl *<\/p>\n<p>Status&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : OK     <br \/>Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : ACPI      <br \/>State&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : Running      <br \/>ExitCode&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : 0      <br \/>Started&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : True      <br \/>ServiceSpecificExitCode : 0      <br \/>__GENUS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : 2      <br \/>__CLASS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : Win32_SystemDriver      <br \/>__SUPERCLASS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : Win32_BaseService      <br \/>__DYNASTY&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : CIM_ManagedSystemElement      <br \/>__RELPATH&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : Win32_SystemDriver.Name=&#8221;ACPI&#8221;      <br \/>__PROPERTY_COUNT&nbsp;&nbsp;&nbsp;&nbsp; : 22      <br \/>__DERIVATION&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : {Win32_BaseService, CIM_Service, CIM_LogicalElement, CIM_M      <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; anagedSystemElement}      <br \/>__SERVER&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : MRED1      <br \/>__NAMESPACE&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : root\\cimv2      <br \/>__PATH&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : \\\\MRED1\\root\\cimv2:Win32_SystemDriver.Name=&#8221;ACPI&#8221;      <br \/>AcceptPause&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : False      <br \/>AcceptStop&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : True      <br \/>Caption&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : Microsoft ACPI Driver      <br \/>CreationClassName&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : Win32_SystemDriver      <br \/>Description&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : Microsoft ACPI Driver      <br \/>DesktopInteract&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : False      <br \/>DisplayName&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : Microsoft ACPI Driver      <br \/>ErrorControl&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : Critical      <br \/>InstallDate&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :      <br \/>PathName&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : C:\\Windows\\system32\\DRIVERS\\ACPI.sys      <br \/>ServiceType&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : Kernel Driver      <br \/>StartMode&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : Boot      <br \/>StartName&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :      <br \/>SystemCreationClassName : Win32_ComputerSystem      <br \/>SystemName&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : MRED1      <br \/>TagId : 1      <br \/>Scope&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : System.Management.ManagementScope      <br \/>Path&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : \\\\MRED1\\root\\cimv2:Win32_SystemDriver.Name=&#8221;ACPI&#8221;      <br \/>Options&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : System.Management.ObjectGetOptions      <br \/>ClassPath&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : \\\\MRED1\\root\\cimv2:Win32_SystemDriver      <br \/>Properties&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : {AcceptPause, AcceptStop, Caption, CreationClassName&#8230;}      <br \/>SystemProperties&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : {__GENUS, __CLASS, __SUPERCLASS, __DYNASTY&#8230;}      <br \/>Qualifiers&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : {dynamic, Locale, provider, UUID}      <br \/>Site&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :      <br \/>Container&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :<\/p>\n<p>PS C:\\&gt;<\/p>\n<\/blockquote>\n<p>One of the things that makes using the <strong>[WMI]<\/strong> type accelerator difficult to use is that it requires a key to a specific instance of a WMI class. But the cool thing is we get keys to specific instances of classes for free when using a WMI association class. This makes working with association classes extremely flexible and easy when using Windows PowerShell. <\/p>\n<p>The <strong>GroupComponent<\/strong> and the <strong>PartComponent<\/strong> properties are described as a reference to another class. The reference to the other class is the key to the class in path form, and when using the <strong>[WMI]<\/strong> type accelerator, we use the path to the other class to return an instance of that class. This means that all of the properties from the <strong>Win32_BaseService<\/strong> and <strong>Win32_LoadOrderGroup<\/strong> are available to us. <\/p>\n<p>It is this reference to another WMI class concept that fakes students of WMI out at first glance. They see the property <strong>GroupOrder<\/strong> or <strong>Started<\/strong> being used in the script, and wonder from where it comes. The properties are coming from the referenced WMI classes. The results of the <strong>Get-WmiObject<\/strong> WMI query are piped to the <a href=\"http:\/\/www.bing.com\/visualsearch?g=powershell_cmdlets&amp;FORM=Z9GE22\">ForEach-Object cmdlet<\/a> to allow us to work with each object as it comes across the <a href=\"http:\/\/www.microsoft.com\/technet\/scriptcenter\/topics\/winpsh\/manual\/pipe.mspx\">pipeline<\/a>. This is shown here:<\/p>\n<blockquote>\n<p>Get-WmiObject -Class win32_LoadOrderGroupServiceMembers |<\/p>\n<p>ForEach-Object {<\/p>\n<\/blockquote>\n<p>Because we want to return information from each of the two WMI classes that are referenced, I decided to use the <strong>New-Object<\/strong> cmdlet to create a new object, and then use a hash table to add four properties to the object. The properties are the group order number, the name of the group, the service name, and whether the service is started. This section of the script is shown here:<\/p>\n<blockquote>\n<p>New-Object -TypeName psobject -Property `<\/p>\n<p>&nbsp;&nbsp; @{<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp; &#8220;GroupOrder&#8221;=([wmi]$_.GroupComponent).GroupOrder<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp; &#8220;GroupName&#8221;=([wmi]$_.GroupComponent).Name<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp; &#8220;ServiceName&#8221;=([wmi]$_.PartComponent).Name<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp; &#8220;Started&#8221;=([wmi]$_.PartComponent).Started<\/p>\n<p>&nbsp;&nbsp;&nbsp; }<\/p>\n<\/blockquote>\n<p>The cool thing about creating a custom Windows PowerShell object is that regular Windows PowerShell cmdlets can be used to manipulate the results that come from the query. Therefore, the first thing I am interested in seeing is only the services that are started. The <strong>Where-Object<\/strong> cmdlet is used to filter out only services that are started. Because the started property is a Boolean value, we can use a shortcut method as shown here: <\/p>\n<blockquote>\n<p>Where-Object { $_.started } |<\/p>\n<\/blockquote>\n<p>The above command is the same as saying only return objects that have a value for the started property of <strong>$true<\/strong>. This command is shown here:<\/p>\n<blockquote>\n<p>Where-Object { $_.started -eq $true }<\/p>\n<\/blockquote>\n<p>After the started services have been filtered, they are piped to the <strong>Sort-Object<\/strong> cmdlet, which is used to sort the services into their start order group in a descending fashion. This portion of the command is shown here:<\/p>\n<blockquote>\n<p>Sort-Object -Property grouporder &ndash;Descending<\/p>\n<\/blockquote>\n<p>When the script runs, the output is displayed that is shown in the following image. <\/p>\n<p><a href=\"https:\/\/docs.microsoft.com\/\"><img decoding=\"async\" height=\"396\" width=\"554\" src=\"https:\/\/docs.microsoft.com\/\" alt=\"Image of output displayed when script runs\" border=\"0\" title=\"Image of output displayed when script runs\" style=\"border-bottom: 0px;border-left: 0px;padding-left: 0px;padding-right: 0px;border-top: 0px;border-right: 0px;padding-top: 0px\" \/><\/a><\/p>\n<p>RY, that is all there is to using WMI to display the service load groups for running services. This also concludes WMI Week. Join us tomorrow for <a href=\"http:\/\/blogs.technet.com\/b\/heyscriptingguy\/archive\/tags\/quick_2d00_hits+friday\/\">Quick-Hits Friday<\/a>.<\/p>\n<p>We would love for you to follow us on <a href=\"http:\/\/bit.ly\/scriptingguystwitter\">Twitter<\/a> and <a href=\"http:\/\/bit.ly\/scriptingguysfacebook\">Facebook<\/a>. If you have any questions, send email to us at <a href=\"mailto:scripter@microsoft.com\">scripter@microsoft.com<\/a>, or post your questions on the <a href=\"http:\/\/social.technet.microsoft.com\/Forums\/en\/ITCG\/threads\/\">Official Scripting Guys Forum.<\/a>. See you tomorrow. Until then, peace.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Ed Wilson and Craig Liebendorfer, Scripting Guys<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Summary: The Microsoft Scripting Guys show how to determine service launch order by using Windows PowerShell and WMI in this helpful step-by-step article. &nbsp; Hey, Scripting Guy! I need to find out the order in which services start on my computer. To properly shut down a computer, the services should stop in reverse order that [&hellip;]<\/p>\n","protected":false},"author":595,"featured_media":87096,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[31,3,4,39,45,6],"class_list":["post-17241","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-operating-system","tag-scripting-guy","tag-scripting-techniques","tag-services","tag-windows-powershell","tag-wmi"],"acf":[],"blog_post_summary":"<p>Summary: The Microsoft Scripting Guys show how to determine service launch order by using Windows PowerShell and WMI in this helpful step-by-step article. &nbsp; Hey, Scripting Guy! I need to find out the order in which services start on my computer. To properly shut down a computer, the services should stop in reverse order that [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/17241","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/users\/595"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/comments?post=17241"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/17241\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media\/87096"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media?parent=17241"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=17241"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=17241"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}