xService: cannot be used for Computer Browser Service if it is not installed #765
Labels
enhancement
The issue is an enhancement request.
good first issue
The issue should be easier to fix and can be taken up by a beginner to learn to contribute on GitHub
help wanted
The issue is up for grabs for anyone in the community.
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:
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
DSC configuration
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
PowerShell version and build the target node is running
xPSDesiredStateConfiguration version
The text was updated successfully, but these errors were encountered: