{"id":16551,"date":"2010-11-10T00:01:00","date_gmt":"2010-11-10T00:01:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2010\/11\/10\/use-powershell-to-work-with-the-net-framework-service-classes\/"},"modified":"2010-11-10T00:01:00","modified_gmt":"2010-11-10T00:01:00","slug":"use-powershell-to-work-with-the-net-framework-service-classes","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/use-powershell-to-work-with-the-net-framework-service-classes\/","title":{"rendered":"Use PowerShell to Work with the .NET Framework Service Classes"},"content":{"rendered":"<p>&nbsp;<\/p>\n<p><b>Summary:<\/b> Learn how to use Windows PowerShell to work with the .NET Framework service controller classes.<\/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 am curious about the .NET Framework. I tried to use a .NET Framework class in a Windows PowerShell script recently, and the script seems to run erratically. Because I am in the middle of troubleshooting the script this is really frustrating. To be honest, I cannot tell if a change I make to the script is what causes the script to run correctly, or if it is something else.<\/p>\n<p>&#8212; TA<\/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\/a-for-powertip.jpg\" align=\"left\" alt=\"Hey, Scripting Guy! Answer\" border=\"0\" title=\"Hey, Scripting Guy! Answer\" \/>Hello TA, Microsoft Scripting Guy Ed Wilson here. It is amazing how much I take computers for granted. Most of the time, the computers just work and I do not have to do much troubleshooting. I have a dozen physical computers on my network at home (10 of them are in my office which keeps me nice and warm in the winter. Of course, they keep me nice and warm in the summer, too). The nice thing is that when one of my computers does cause problems, I have the skills to be able to diagnose the problem quickly. <\/p>\n<p>In one respect Windows PowerShell is like this, in that most of the time, it simply works. When straying from the safety net of Windows PowerShell into the &#8220;uncharted waters&#8221; of the .NET Framework, problems can arise. Not that the .NET Framework classes are uncharted waters, there are thousands of pages worth of information about the <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/gg145045.aspx\">.NET Framework on MSDN<\/a>. However, it can feel like one is adrift because all the things that Windows PowerShell does automatically now have to be done manually. <\/p>\n<p>An example is the <b>Get-Service<\/b> Windows PowerShell cmdlet. Typing a single command <b>Get-Service<\/b> returns a nice display of information about services on the local machine. The command appears here. <\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">Get-Service<\/span><\/p>\n<p>&nbsp;<\/p>\n<p>The output from that single command appears in the following figure.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/2781.HSG-11-10-10-01.jpg\" border=\"0\" \/>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>By piping the output from the <b>Get-Service<\/b> Windows PowerShell cmdlet to the <b>Get-Member<\/b> cmdlet, I can see what kind of object I am working with. The output from this sequence of two commands is here.<\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">PS C:\\&gt; Get-Service | Get-Member<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">&nbsp;<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">&nbsp;<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">&nbsp;&nbsp; TypeName: System.ServiceProcess.ServiceController<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">&nbsp;<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MemberType&nbsp;&nbsp;&nbsp; Definition<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">&#8212;-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8212;&#8212;&#8212;-&nbsp;&nbsp;&nbsp; &#8212;&#8212;&#8212;-<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; AliasProperty Name = ServiceName<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">RequiredServices&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; AliasProperty RequiredServices = ServicesDependedOn<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">Disposed&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Event&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.EventHandler Disposed(System.Objec&#8230;<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">Close&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.Void Close()<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">Continue&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.Void Continue()<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">CreateObjRef&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.Runtime.Remoting.ObjRef CreateObjR&#8230;<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">Dispose&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.Void Dispose()<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">Equals&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bool Equals(System.Object obj)<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">ExecuteCommand&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.Void ExecuteCommand(int command)<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">GetHashCode&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int GetHashCode()<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">GetLifetimeService&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.Object GetLifetimeService()<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">GetType&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; type GetType()<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">InitializeLifetimeService Method&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.Object InitializeLifetimeService()<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">Pause&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.Void Pause()<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">Refresh&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.Void Refresh()<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">Start&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.Void Start(), System.Void Start(st&#8230;<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">Stop&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.Void Stop()<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">ToString&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string ToString()<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">WaitForStatus&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.Void WaitForStatus(System.ServiceP&#8230;<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">CanPauseAndContinue&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Property&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.Boolean CanPauseAndContinue {get;}<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">CanShutdown&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Property&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.Boolean CanShutdown {get;}<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">CanStop&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Property&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.Boolean CanStop {get;}<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">Container&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Property&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.ComponentModel.IContainer Containe&#8230;<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">DependentServices&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Property&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.ServiceProcess.ServiceController[]&#8230;<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">DisplayName&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Property&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.String DisplayName {get;set;}<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">MachineName&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Property&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.String MachineName {get;set;}<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">ServiceHandle&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Property&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.Runtime.InteropServices.SafeHandle&#8230;<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">ServiceName&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Property&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.String ServiceName {get;set;}<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">ServicesDependedOn&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Property&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.ServiceProcess.ServiceController[]&#8230;<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">ServiceType&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Property&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.ServiceProcess.ServiceType Service&#8230;<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">Site&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Property&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.ComponentModel.ISite Site {get;set;}<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">Status&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Property&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.ServiceProcess.ServiceControllerSt&#8230;<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">&nbsp;<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">&nbsp;<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">PS C:\\&gt;<\/span><\/p>\n<p>&nbsp;<\/p>\n<p>The .NET Framework class that is behind the <b>Get-Service<\/b> Windows PowerShell cmdlet is therefore the <b>System.ServiceProcess.ServiceController<\/b> class. The class name is <b>ServiceController<\/b>, and the .NET Framework namespace is <b>System.ServiceProcess<\/b>. If I put the namespace and class name in square brackets I will retrieve a bit of information that tells me the class is available for use. This is seen here.<\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">PS C:\\&gt; [System.ServiceProcess.ServiceController]<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">&nbsp;<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">IsPublic IsSerial 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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;BaseType<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">&#8212;&#8212;&#8211; &#8212;&#8212;&#8211; &#8212;-&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; &#8212;&#8212;&#8211;<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">True&nbsp;&nbsp;&nbsp;&nbsp; False&nbsp;&nbsp;&nbsp; ServiceController&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.ComponentModel&#8230;.<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">&nbsp;<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">&nbsp;<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">PS C:\\&gt;<\/span><\/p>\n<p>&nbsp;<\/p>\n<p>As soon as I know a .NET Framework class is available, I can use the <b>Get-Member<\/b> Windows PowerShell cmdlet to retrieve its static members. To do this, I <a href=\"http:\/\/www.microsoft.com\/technet\/scriptcenter\/topics\/winpsh\/manual\/pipe.mspx\">pipeline<\/a> the .NET Framework class (together with its namespace) to the <b>Get-Member<\/b> cmdlet and use the <b>-static<\/b> switch. This command and its associated output appear here.<\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">PS C:\\&gt; [System.ServiceProcess.ServiceController] | Get-Member -Static<\/p>\n<p>&nbsp;&nbsp; TypeName: System.ServiceProcess.ServiceController<\/p>\n<p>Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MemberType Definition<br \/>&#8212;-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8212;&#8212;&#8212;- &#8212;&#8212;&#8212;-<br \/>Equals&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp; static bool Equals(System.Object objA, System.Object o&#8230;<br \/>GetDevices&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp; static System.ServiceProcess.ServiceController[] GetDe&#8230;<br \/>GetServices&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp; static System.ServiceProcess.ServiceController[] GetSe&#8230;<br \/>ReferenceEquals Method&nbsp;&nbsp;&nbsp;&nbsp; static bool ReferenceEquals(System.Object objA, System&#8230;<\/p>\n<p>PS C:\\&gt;<\/span><\/p>\n<p>&nbsp;<\/p>\n<p>Now there are two static methods that look really interesting, and two static methods that always appear in the output (because they are inherited from the <b>System.Object<\/b> .NET Framework class). The two static methods that I want to explore are <b>GetDevices<\/b> and <b>GetServices<\/b>. I can call the <b>GetDevices<\/b> method by using double colons as shown here.<\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">PS C:\\&gt; [System.ServiceProcess.ServiceController]::GetDevices()<\/p>\n<p>Status&nbsp;&nbsp; Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DisplayName<br \/>&#8212;&#8212;&nbsp;&nbsp; &#8212;-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8212;&#8212;&#8212;&#8211;<br \/>Stopped&nbsp; 1394ohci&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1394 OHCI Compliant Host Controller<br \/>Running&nbsp; ACPI&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Microsoft ACPI Driver<br \/>Stopped&nbsp; AcpiPmi&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ACPI Power Meter Driver<br \/>Running&nbsp; ADIHdAudAddService ADI UAA Function Driver for High De&#8230;<br \/>Stopped&nbsp; adp94xx&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; adp94xx<br \/>Stopped&nbsp; adpahci&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; adpahci<br \/>Stopped&nbsp; adpu320&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; adpu320<\/span><\/p>\n<p style=\"padding-left: 30px\">&lt;output <a href=\"http:\/\/encarta.msn.com\/dictionary_1861722246\/truncated.html\">truncated<\/a>&gt;<\/p>\n<p>&nbsp;<\/p>\n<p>Similarly, I can call the <b>GetServices<\/b> static method from [<b>System.ServiceProcess.ServiceController<\/b>] by using the command shown here.<\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">[System.ServiceProcess.ServiceController]::GetServices()<\/span><\/p>\n<p>&nbsp;<\/p>\n<p>The output from the <b>GetServices<\/b> static method is seen in the following figure.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/4011.HSG-11-10-10-02.jpg\" border=\"0\" \/>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>A quick comparison of the output from <b>Get-Service<\/b> with the output from <b>[System.ServiceProcess.ServiceController]::GetServices()<\/b> reveals that the two commands are identical. Therefore, there is no reason to mess around with calling the <b>GetServices<\/b> static method from the <b>ServiceController<\/b> class. On the other hand, calling the <b>GetDevices<\/b> static method is useful because it provides a great view of device drivers, and this information is not exposed from the <b>Get-Service<\/b> Windows PowerShell cmdlet. <\/p>\n<p>Now, close the Windows PowerShell console. Open it back up, and type <b>[System.ServiceProcess.ServiceController]<\/b> to make sure the .NET Framework <b>ServiceController<\/b> class is available. The output of this operation causes an error, as seen here.<\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">PS C:\\&gt; [System.ServiceProcess.ServiceController]<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">&nbsp;<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">Unable to find type [System.ServiceProcess.ServiceController]: make sure that the as<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">sembly containing this type is loaded.<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">At line:1 char:42<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">+ [System.ServiceProcess.ServiceController] &lt;&lt;&lt;&lt;<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">&nbsp;&nbsp;&nbsp; + CategoryInfo&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : InvalidOperation: (System.ServiceProcess.ServiceContr<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">&nbsp;&nbsp; oller:String) [], RuntimeException<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">&nbsp;&nbsp;&nbsp; + FullyQualifiedErrorId : TypeNotFound<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">&nbsp;<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">PS C:\\&gt;<\/span><\/p>\n<p>&nbsp;<\/p>\n<p>The error generated by the previous command tells me that Windows PowerShell cannot find the assembly that contains the <b>[System.ServiceProcess.ServiceController] <\/b>class. This means that we cannot use the <b>ServiceController<\/b> class directly. <\/p>\n<p>Now type <b>Get-Service<\/b> and press <b>Enter<\/b> to run the <b>Get-Service<\/b> Windows PowerShell cmdlet. The output that contains information about the installed services on my machine appears. Now press the <b>Up Arrow<\/b>, to retrieve the <b>[System.ServiceProcess.ServiceController]<\/b> command. Pressing <b>Enter<\/b> this time, reveals the output that tells me that the class is available.<\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">PS C:\\&gt; [System.ServiceProcess.ServiceController]<\/p>\n<p>IsPublic IsSerial 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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; BaseType<br \/>&#8212;&#8212;&#8211; &#8212;&#8212;&#8211; &#8212;-&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;&#8212;&#8212;&#8211;<br \/>True&nbsp;&nbsp;&nbsp;&nbsp; False&nbsp;&nbsp;&nbsp; ServiceController&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.ComponentModel&#8230;.<\/p>\n<p>PS C:\\&gt;<\/span><\/p>\n<p>&nbsp;<\/p>\n<p>Well, what happened? It seems that the <b>Get-Service<\/b> Windows PowerShell cmdlet automatically loads the assembly that contains the <b>ServiceController<\/b> .NET Framework class. The easiest way to find information about a .NET Framework class&#8217;s assembly is to use <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/system.serviceprocess.servicecontroller.aspx\">MSDN<\/a>. The MSDN article for the <b>ServiceController<\/b> class is shown in the following figure.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/3755.HSG-11-10-10-03.jpg\" border=\"0\" \/>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>The assembly information for a .NET Framework class is always found on the main page for the class, in the Inheritance Hierarchy portion if the page. For the <b>ServiceController<\/b> class, the assembly and the namespace have the same name. Both are called <b>System.ServiceProcess<\/b>. While this is true of a good many .NET Framework classes, it is not true of all .NET Framework classes. Therefore, it is not safe to assume that the assembly name and the namespace name will always be the same. To load the <b>System.ServiceProcess<\/b> assembly that contains the <b>ServiceController<\/b> class, use the <b>Add-Type<\/b> cmdlet in <a href=\"http:\/\/support.microsoft.com\/kb\/968929\">Windows PowerShell 2.0<\/a>. If, for some reason, you are still using Windows PowerShell 1.0, and you cannot upgrade to Windows PowerShell 2.0, you can load the assembly by using the assembly class from the <b>System.Reflection<\/b> .NET Framework namespace. The command uses the <b>LoadWithPartialName<\/b> static method and it is shown here.<\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">PS C:\\&gt; [system.reflection.assembly]::LoadwithPartialName(&#8220;System.ServiceProcess&#8221;)<\/p>\n<p>GAC&nbsp;&nbsp;&nbsp; Version&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Location<br \/>&#8212;&nbsp;&nbsp;&nbsp; &#8212;&#8212;-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8212;&#8212;&#8211;<br \/>True&nbsp;&nbsp; v2.0.50727&nbsp;&nbsp;&nbsp;&nbsp; C:\\Windows\\assembly\\GAC_MSIL\\System.ServiceProcess\\2.0.0.0_&#8230;<\/p>\n<p>PS C:\\&gt;<\/span><\/p>\n<p>&nbsp;<\/p>\n<p>The <b>LoadWithPartialName<\/b> static method is actually obsolete according to <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/system.reflection.assembly.aspx\">MSDN<\/a>. To load an assembly by using the <b>Assembly<\/b> .NET Framework class, you should actually use the load method. Unfortunately, the load method is more difficult to use because you must tell it which exact version of the assembly to use. This is why I like to use the <b>Add-Type<\/b> Windows PowerShell cmdlet instead. It is much easier to use. To show this: close Windows PowerShell, and open it back up again. Use the <i>-assemblyname<\/i> parameter to specify the <b>System.ServiceProcess<\/b> assembly. After this is completed, type the <b>[System.ServiceProcess.ServiceController]<\/b> class to make sure it is available. This is shown here.<\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">PS C:\\&gt; Add-Type -assemblyname System.ServiceProcess<br \/>PS C:\\&gt; [System.ServiceProcess.ServiceController]<\/p>\n<p>IsPublic IsSerial 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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; BaseType<br \/>&#8212;&#8212;&#8211; &#8212;&#8212;&#8211; &#8212;-&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;&#8212;&#8212;&#8211;<br \/>True&nbsp;&nbsp;&nbsp;&nbsp; False&nbsp;&nbsp;&nbsp; ServiceController&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.ComponentModel&#8230;.<\/span><\/p>\n<p>&nbsp;<\/p>\n<p>No feedback is returned from using the <b>Add-Type<\/b> Windows PowerShell cmdlet to load the assembly. However, if the assembly name is misspelled, and error will appear as shown here.<\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">PS C:\\&gt; Add-Type -assemblyname System.ServiceProc<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">Add-Type : Cannot add type. The assembly &#8216;System.ServiceProc&#8217; could not be found.<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">At line:1 char:9<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">+ Add-Type &lt;&lt;&lt;&lt;&nbsp; -assemblyname System.ServiceProc<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">&nbsp;&nbsp;&nbsp; + CategoryInfo&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : ObjectNotFound: (System.ServiceProc:String) [Add-Type<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">&nbsp;&nbsp; ], Exception<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">&nbsp;&nbsp;&nbsp; + FullyQualifiedErrorId : ASSEMBLY_NOT_FOUND,Microsoft.PowerShell.Commands.AddT<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">&nbsp;&nbsp; ypeCommand<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">&nbsp;<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">Add-Type : Cannot add type. One or more required assemblies are missing.<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">At line:1 char:9<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">+ Add-Type &lt;&lt;&lt;&lt;&nbsp; -assemblyname System.ServiceProc<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">&nbsp;&nbsp;&nbsp; + CategoryInfo&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : InvalidData: (:) [Add-Type], InvalidOperationExceptio<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">&nbsp;&nbsp; n<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">&nbsp;&nbsp;&nbsp; + FullyQualifiedErrorId : ASSEMBLY_LOAD_ERRORS,Microsoft.PowerShell.Commands.Ad<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">&nbsp;&nbsp; dTypeCommand<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">&nbsp;<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">PS C:\\&gt;<\/span><\/p>\n<p>&nbsp;<\/p>\n<p>One other thing to be aware of is that the <i>-assemblyname<\/i> parameter is required. You cannot use the <b>Add-Type<\/b> cmdlet to load an assembly and rely on a positional parameter. This is seen here.<\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">PS C:\\&gt; Add-Type system.serviceprocess<br \/>Add-Type : c:\\Users\\ed.NWTRADERS\\AppData\\Local\\Temp\\vctcnhpk.0.cs(1) : A namespace d<br \/>oes not directly contain members such as fields or methods<br \/>c:\\Users\\ed.NWTRADERS\\AppData\\Local\\Temp\\vctcnhpk.0.cs(1) : &gt;&gt;&gt; system.serviceproces<br \/>s<br \/>At line:1 char:9<br \/>+ Add-Type &lt;&lt;&lt;&lt;&nbsp; system.serviceprocess<br \/>&nbsp;&nbsp;&nbsp; + CategoryInfo&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : InvalidData: (c:\\Users\\ed.NWT&#8230;elds or methods:Compi<br \/>&nbsp;&nbsp; lerError) [Add-Type], Exception<br \/>&nbsp;&nbsp;&nbsp; + FullyQualifiedErrorId : SOURCE_CODE_ERROR,Microsoft.PowerShell.Commands.AddTy<br \/>&nbsp;&nbsp; peCommand<\/p>\n<p>Add-Type : Cannot add type. There were compilation errors.<br \/>At line:1 char:9<br \/>+ Add-Type &lt;&lt;&lt;&lt;&nbsp; system.serviceprocess<br \/>&nbsp;&nbsp;&nbsp; + CategoryInfo&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : InvalidData: (:) [Add-Type], InvalidOperationExceptio<br \/>&nbsp;&nbsp; n<br \/>&nbsp;&nbsp;&nbsp; + FullyQualifiedErrorId : COMPILER_ERRORS,Microsoft.PowerShell.Commands.AddType<br \/>&nbsp;&nbsp; Command<\/span><\/p>\n<p>&nbsp;<\/p>\n<p>In addition, while you can leave the <a href=\"http:\/\/gallery.technet.microsoft.com\/ScriptCenter\/en-us\/site\/search?f%5B0%5D.Type=RootCategory&amp;f%5B0%5D.Value=office&amp;f%5B0%5D.Text=Office&amp;f%5B1%5D.Type=SubCategory&amp;f%5B1%5D.Value=word&amp;f%5B1%5D.Text=Microsoft%20Word\">Word<\/a> system off, when calling the class, you cannot leave off the word system when loading the assembly. This is illustrated here, where I generate an error.<\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">PS C:\\&gt; Add-Type -assembly serviceprocess<br \/>Add-Type : Cannot add type. The assembly &#8216;serviceprocess&#8217; could not be found.<br \/>At line:1 char:9<br \/>+ Add-Type &lt;&lt;&lt;&lt;&nbsp; -assembly serviceprocess<br \/>&nbsp;&nbsp;&nbsp; + CategoryInfo&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : ObjectNotFound: (serviceprocess:String) [Add-Type], E<br \/>&nbsp;&nbsp; xception<br \/>&nbsp;&nbsp;&nbsp; + FullyQualifiedErrorId : ASSEMBLY_NOT_FOUND,Microsoft.PowerShell.Commands.AddT<br \/>&nbsp;&nbsp; ypeCommand<\/p>\n<p>Add-Type : Cannot add type. One or more required assemblies are missing.<br \/>At line:1 char:9<br \/>+ Add-Type &lt;&lt;&lt;&lt;&nbsp; -assembly serviceprocess<br \/>&nbsp; &nbsp;&nbsp;+ CategoryInfo&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : InvalidData: (:) [Add-Type], InvalidOperationExceptio<br \/>&nbsp;&nbsp; n<br \/>&nbsp;&nbsp;&nbsp; + FullyQualifiedErrorId : ASSEMBLY_LOAD_ERRORS,Microsoft.PowerShell.Commands.Ad<br \/>&nbsp;&nbsp; dTypeCommand<\/span><\/p>\n<p>&nbsp;<\/p>\n<p>The assembly name is not case-sensitive. After the assembly has been loaded, the word system can be left off if you want. This is shown here.<\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">PS C:\\&gt; Add-Type -AssemblyName system.serviceprocess<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">PS C:\\&gt; [serviceprocess.servicecontroller]<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">&nbsp;<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">IsPublic IsSerial 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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; BaseType<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">&#8212;&#8212;&#8211; &#8212;&#8212;&#8211; &#8212;-&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; &#8212;&#8212;&#8211;<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">True&nbsp;&nbsp;&nbsp;&nbsp; False&nbsp;&nbsp;&nbsp; ServiceController&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.ComponentModel&#8230;.<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">&nbsp;<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">&nbsp;<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: courier new,courier\">PS C:\\&gt;<\/span><\/p>\n<p>&nbsp;<\/p>\n<p>TA, that is all there is to working with the <b>ServiceController<\/b> .NET Framework class. .NET Framework week will continue tomorrow when I continue to work with the .NET Framework classes. <\/p>\n<p>I invite you to follow me on <a target=\"_blank\" href=\"http:\/\/bit.ly\/scriptingguystwitter\">Twitter<\/a> or <a href=\"http:\/\/bit.ly\/scriptingguysfacebook\">Facebook<\/a>. If you have any questions, send email to me at <a target=\"_blank\" href=\"mailto:scripter@microsoft.com\">scripter@microsoft.com<\/a> or post them 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><b>Ed Wilson, Microsoft Scripting Guy<\/b><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; Summary: Learn how to use Windows PowerShell to work with the .NET Framework service controller classes. &nbsp; Hey, Scripting Guy! I am curious about the .NET Framework. I tried to use a .NET Framework class in a Windows PowerShell script recently, and the script seems to run erratically. Because I am in the middle [&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":[66,31,3,39,45],"class_list":["post-16551","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-net-framework","tag-operating-system","tag-scripting-guy","tag-services","tag-windows-powershell"],"acf":[],"blog_post_summary":"<p>&nbsp; Summary: Learn how to use Windows PowerShell to work with the .NET Framework service controller classes. &nbsp; Hey, Scripting Guy! I am curious about the .NET Framework. I tried to use a .NET Framework class in a Windows PowerShell script recently, and the script seems to run erratically. Because I am in the middle [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/16551","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=16551"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/16551\/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=16551"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=16551"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=16551"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}