-
Notifications
You must be signed in to change notification settings - Fork 225
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SqlWindowsFirewall: Duplicate Browser Firewall Rule for AS feature creates Error in subsequent Test-TargetResource runs #1942
Comments
I suggest to set SqlServerDsc/source/DSCResources/DSC_SqlWindowsFirewall/DSC_SqlWindowsFirewall.psm1 Line 477 in f9bde8a
SqlServerDsc/source/DSCResources/DSC_SqlWindowsFirewall/DSC_SqlWindowsFirewall.psm1 Line 546 in f9bde8a
That will make sure it won't try to add it twice on the first run. |
Happy to review a PR that fixes this. |
…eates Error in subsequent Test-TargetResource runs (dsccommunity#1942)
Hi and thanks a lot for your immediate action on this issue and of course for maintaining this great project! Since I am new to this process it took me a moment to get familiar with it, I hope I managed to adhere to the guidelines. Feel free to correct me where I failed to do so. |
Problem description
Issue
Running the configuration (see below) for the first time works fine but subsequent runs throw an error message (see below).
Reason
Running the configuration for the first time:
The Set-TargetResource will create a firewall rule for the SQL Server Browser with a DisplayName of 'SQL Server Browser' for the feature 'SQLENGINE'. In the feature switch block for 'AS' it will create the same firewall rule again, since $getTargetResourceResult.BrowserFirewall is still false.
Running the configuration for the second (and subsequent) time:
Test-TargetResource calls Get-TargetResource which calls Test-IsFirewallRuleInDesiredState. When running Test-IsFirewallRuleInDesiredState with @browserFirewallRuleParameters, the following line will throw an error:
$firewallServiceFilter = Get-NetFirewallServiceFilter -AssociatedNetFirewallRule $firewallRule -ErrorAction 'SilentlyContinue'
since the parameter $firewallRule holds an array of two firewall rules with DisplayName 'SQL Server Browser'. Specifying the ErrorAction does not have an effect, however if one specifies $ErrorActionPreference = "SilentlyContinue" the error is not thrown. This is not a viable solution since one would like to know about other errors thrown by the configuration.
Verbose logs
DSC configuration
Suggested solution
Check for the existence of the 'SQL Server Browser' firewall rule before creating it in the Set-TargetResource in the 'SQLENGINE' switch block as well as in the 'AS' switch block:
Happy to provide a tiny PR for this, do some testing, deliver more info, or do whatever helps.
SQL Server edition and version
SQL Server PowerShell modules
Operating system
PowerShell version
SqlServerDsc version
The text was updated successfully, but these errors were encountered: