So while working on one of the requests I was interested in finding out the Start mode and startup account for services on a Windows machine.
If you are running Powershell 2.0, then you will need make do with Get-WMIObject. But if you are on Powershell 3.0 and above, then you can use Get-CimInstance.
I have also written an article on how to find the last boot time of remote computers using both Get-WMIObject and Get-CimInstance which you can find here.
Moving on, since we are interested in finding the services, we will be using the Win32_Service Class.
Let us see the properties that are available to us.
Get-CimInstance -ClassName Win32_Service | Get-Member
We are interested in finding out the StartMode, StartName which will give us the account used to start/stop the service and Name will provide us the name of the service.
Get-CimInstance -ClassName win32_service -Property Name, StartName, StartMode | select Name, StartName, StartMode
And if you are using Powershell 2.0, then you need to run the below command which gives the same Output.
Get-WmiObject -Class win32_service -Property Name, StartName, StartMode | select Name, StartName, StartMode
There are lot of other information that you can retrieve using the Win32_Service Class which I will leave it upto you to explore.
Put down your comments if you have a different way of doing this. I would love to hear it.
I want to thank you for reading and spending time on the blog.