-
Notifications
You must be signed in to change notification settings - Fork 133
Description
Problem description
I want to make sure the service "Computer Browser" is not installed on my devices.
Unfortunately there seems to be a Problem combined with the way Get-Service works (-Name also seems to look for DisplayName, if there is no hit) and the fact that Microsoft has this great combination of Services:
| # | Name | DisplayName | Description |
|---|---|---|---|
| 1 | Browser | Computer Browser | This is a "normal" service, that you can see in Services.msc |
| 2 | Bowser | Browser | Apparently this is the "Browser Support Driver" |
As a result, Get-Service, which is called in line 52 of DSC_xServiceResource.psm1 returns the Bowser Service, rather than the Browser, which I am looking for. Regardless of Browser only being the DisplayName and not Name.
Next, it tries to execute "Get-ServiceCimInstance -ServiceName $Name", which will be empty, as this won't work for Bowser Service.
This then leads to the String-Conversion failing, as there is no return value from and thus no StartMode
($startupType = ConvertTo-StartupTypeString -StartMode $serviceCimInstance.StartMode)
Verbose logs
PowerShell DSC resource DSC_xServiceResource failed to execute Test-TargetResource functionality with error message: The property 'StartMode' cannot be found on this object. Verify that the property exists.
+ CategoryInfo : InvalidOperation: (:) [], CimException
+ FullyQualifiedErrorId : ProviderOperationExecutionFailure
+ PSComputerName : DESKTOP-55FBL3B
DSC configuration
instance of DSC_xServiceResource as $DSC_xServiceResource1ref
{
Name = "Browser";
Ensure = "Absent";
ModuleName = "xPSDesiredStateConfiguration";
ResourceID = "[xService]Browser";
ModuleVersion = "9.1.0";
ConfigurationName = "ServiceConfig";
};
instance of OMI_ConfigurationDocument
{
Version="2.0.0";
MinimumCompatibleVersion = "1.0.0";
CompatibleVersionAdditionalProperties= {"Omi_BaseResource:ConfigurationName"};
};Suggested solution
Imo, Get-Service should not fall back to DisplayName, but I don't think that will ever happen.
So, maybe a check if (get-service -name browser).Name (in this case Bowser) equals the input-value when checking the Service (in this case "Browser")
Operating system the target node is running
OsName : Microsoft Windows 10 Pro
OsOperatingSystemSKU : 48
OsArchitecture : 64-bit
WindowsVersion : 2009
WindowsBuildLabEx : 19041.1.amd64fre.vb_release.191206-1406
OsLanguage : en-US
OsMuiLanguages : {en-US}
PowerShell version and build the target node is running
Name Value
---- -----
PSVersion 5.1.19041.2364
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.19041.2364
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
xPSDesiredStateConfiguration version
Name Version Path
---- ------- ----
xPSDesiredStateConfiguration 9.1.0 C:\Program Files\WindowsPowerShell\Modules\xPSDesiredStateConfiguration\9.1.0\xPSDesiredStateConfiguration.psd1