Following the release of the 0.6.0 version of Chocolatey Central Management, depending on the current configuration/setup of a machine, the chocolatey-management-service package can fail to install, with the following error:
Cannot convert the "System.Object[]" value of type "System.Object[]" to type "System.Int32".
The problematic piece of code is the following:
$portList = [System.Collections.Generic.HashSet[int]]@(
# Get Port Number(s) from firewall rule, if any
Get-NetFirewallRule -DisplayName "Chocolatey Central Management Port" -ErrorAction Ignore |
Get-NetFirewallPortFilter |
Select-Object -ExpandProperty LocalPort
# Get Port Number from chocolatey.config file
if ($env:ChocolateyInstall) {
$configFile = Join-Path $env:ChocolateyInstall -ChildPath "config/chocolatey.config"
if (Test-Path -Path $configFile) {
[xml]$xml = Get-Content -Path $configFile
$xml.chocolatey.config.add |
Where-Object { $_.key -eq 'centralManagementServiceUrl' -And -Not [String]::IsNullOrEmpty($_.value) } |
ForEach-Object {
([uri]$_.value).Port
}
}
}
)
This portList is used to establish a list of port that need to be removed from netsh entries, however, it can fail to establish what these ports are.
If a firewall rule and entry in the chocolatey.config file is found, then the portList is created correctly. If a firewall rule doesn't exist and and entry in the choocolatey.config doesn't exist, then the portList is created correctly If a firewall rule exists and no entry in the chocolatey.config exists, then the portList errors If a firewall rule doesn't exist and an entry in the chocollatey.config exists, the the portList errors
Steps To Reproduce
Find a machine that doesn't currently have the CCM Service installed
Run the following code to remove any firewall rules that might exist
Description
Following the release of the 0.6.0 version of Chocolatey Central Management, depending on the current configuration/setup of a machine, the chocolatey-management-service package can fail to install, with the following error:
The problematic piece of code is the following:
This portList is used to establish a list of port that need to be removed from netsh entries, however, it can fail to establish what these ports are.
If a firewall rule and entry in the chocolatey.config file is found, then the portList is created correctly. If a firewall rule doesn't exist and and entry in the choocolatey.config doesn't exist, then the portList is created correctly If a firewall rule exists and no entry in the chocolatey.config exists, then the portList errors If a firewall rule doesn't exist and an entry in the chocollatey.config exists, the the portList errors
Steps To Reproduce
Output Log
Workarounds
Proposed Solution
Ensure that the portList code works in all possible combinations of values.
Related Issues and Tickets
N/A
Done Checklist
┆Issue is synchronized with this Gitlab issue by Unito ┆Milestone: 0.6.1