Fix : windows_firewall_rule fails to validate more than 1 rule depending on how it's executed #5502
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Signed-off-by: Vasu1105 vasundhara.jagdale@chef.io
Description
windows_firewall_rule is using
Remove-TypeData System.Array
as a workaround for PS bug here: https://bit.ly/2SRMQ8M,Remove-TypeData
Deletes extended types from the current session.Ref So when we are executing more that one rules using different describe blocks as we have already deleted the extended type in the same session when next describe was getting called that command was giving error. due to which the cmd output was coming blank due to which the result was empty for next set of rules.Following is the output of executing the Remove-TypeData in same Poweshell window(same session)
So as a solution we are using
Get-TypeData
command to get extended type in current session and pipe it to theRemove-TypeData
so if there is not System.Array in current session then it will not cause any issue. REF : https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/get-typedata?view=powershell-7.1Related Issue
Fix #5464
Types of changes
Checklist: