Closed ChrisWight closed 7 years ago
I think, intuitively, a Service
test function would be backed by Get-Service
. For scenarios where you need to use CIM there is a generic CimObject function.
In PowerShell 5+, Get-Service
returns the StartType
property.
https://windowsserver.uservoice.com/forums/301869-powershell/suggestions/11699283-get-service-does-not-return-the-service-startup-ty
So, I see where you're coming from, but for this case, I don't think we should change how the Service
function works.
Hi there,
The Service function allows you to specify a property which defaults to Status but due to using Get-Service does not allow you to check the StartMode, to get around this I changed the Service function to use
-TestExpression {Get-wmiobject -class win32_service -Filter "Name = '$Target'"}
and changed the default property to state which then lets you test either.
Is there a reason for using Get-Service over WMI or CIM?
Thanks, Chris