header image

W2KSG: Service Information

Posted by: | September 19, 2008 | No Comment |

We can use get-service to retrieve information regarding the services installed on a system. It doesn’t return all of the information we might want – specifically it doesn’t return the starting mode of the service.  We can get this with WMI

Script Center Home > Microsoft Windows 2000 Scripting Guide > Scripting Concepts and Technologies for System Administration > WMI Scripting Primer  Common Information Model

Listing 6.6

Get-WmiObject -Class win32_service | Select Name, DisplayName, Description, PathName, StartMode, State

Get the Win32_Service class information using Get-WMIObject.  Remember that we can access this information on remote computers by adding -computername name_of_machine. We then use a select to pick out the specific data we are interested in.  We could use -property instead of a select but it returns the WMI specific information that we don’t really need.

__GENUS          : 2
__CLASS          : Win32_Service
__DYNASTY        :
__RELPATH        : Win32_Service.Name="XobniService"
__DERIVATION     : {}
__SERVER         :
__NAMESPACE      :
__PATH           :
Name             : XobniService
StartMode        : Auto
Scope            : System.Management.ManagementScope
Path             : Win32_Service.Name="XobniService"
Options          : System.Management.ObjectGetOptions
ClassPath        : Win32_Service
Properties       : {Name, StartMode}
SystemProperties : {__GENUS, __CLASS, __SUPERCLASS, __DYNASTY…}
Qualifiers       : {dynamic, Locale, provider, UUID}
Site             :
Container        :

In this case using Select gives us more control


Share this post :


Technorati Tags: ,,

under: PowerShell and WMI