February 2019
Intermediate to advanced
626 pages
15h 51m
English
Calling a method on an existing instance of an object found using Get-WmiObject is similar to any .NET method call.
The following example gets and restarts the DNS Client service. The following operation requires administrative access:
$service = Get-WmiObject Win32_Service -Filter "DisplayName='DNS Client'" $service.StopService() # Call the StopService method $service.StartService() # Call the StartService method
The WMI class can be used to find the details of a method; for example, the Create method of Win32_Share, as follows:
PS> (Get-WmiObject Win32_Share -List).Methods['Create']Name : CreateInParameters : System.Management.ManagementBaseObjectOutParameters : System.Management.ManagementBaseObjectOrigin : Win32_Share ...
Read now
Unlock full access