diff --git a/DSCResources/cChocoInstaller/cChocoInstaller.psm1 b/DSCResources/cChocoInstaller/cChocoInstaller.psm1 index d5050ae..1ca852a 100644 --- a/DSCResources/cChocoInstaller/cChocoInstaller.psm1 +++ b/DSCResources/cChocoInstaller/cChocoInstaller.psm1 @@ -134,9 +134,17 @@ function Get-FileDownload { [ValidateNotNullOrEmpty()] [string]$file ) + # Set security protocol preference to avoid the download error if the machine has disabled TLS 1.0 and SSLv3 + # See: https://chocolatey.org/install (Installing With Restricted TLS section) + # Since cChoco requires at least PowerShell 4.0, we have .NET 4.5 available, so we can use [System.Net.SecurityProtocolType] enum values by name. + $securityProtocolSettingsOriginal = [System.Net.ServicePointManager]::SecurityProtocol + [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12 -bor [System.Net.SecurityProtocolType]::Tls11 -bor [System.Net.SecurityProtocolType]::Tls -bor [System.Net.SecurityProtocolType]::Ssl3 + Write-Verbose "Downloading $url to $file" $downloader = new-object -TypeName System.Net.WebClient $downloader.DownloadFile($url, $file) + + [System.Net.ServicePointManager]::SecurityProtocol = $securityProtocolSettingsOriginal } Function Install-Chocolatey { @@ -184,4 +192,4 @@ Function Install-Chocolatey { Write-Verbose 'Finish InstallChoco' } -Export-ModuleMember -Function *-TargetResource \ No newline at end of file +Export-ModuleMember -Function *-TargetResource diff --git a/DSCResources/cChocoSource/cChocoSource.psm1 b/DSCResources/cChocoSource/cChocoSource.psm1 index a0d13cd..7d0d90b 100644 --- a/DSCResources/cChocoSource/cChocoSource.psm1 +++ b/DSCResources/cChocoSource/cChocoSource.psm1 @@ -134,7 +134,7 @@ function Test-TargetResource $chocofolder = $env:ChocolateyInstall } $configfolder = "$chocofolder\config" - $configfile = Get-ChildItem $configfolder | Where-Object {$_.Name -match "chocolatey.config"} + $configfile = Get-ChildItem $configfolder | Where-Object {$_.Name -match "chocolatey.config$"} $xml = [xml](Get-Content $configfile.FullName) $sources = $xml.chocolatey.sources.source @@ -142,8 +142,15 @@ function Test-TargetResource foreach($chocosource in $sources) { if($chocosource.id -eq $name -and $ensure -eq 'Present') - { - return $true + { + if ($chocosource.priority -eq $Priority) + { + return $true + } + else + { + return $false + } } elseif($chocosource.id -eq $name -and $ensure -eq 'Absent') { diff --git a/appveyor.yml b/appveyor.yml index 99de1d9..9bf0a67 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,7 +1,7 @@ -#---------------------------------# -# environment configuration # -#---------------------------------# -version: 2.3.0.{build} +#---------------------------------# +# environment configuration # +#---------------------------------# +version: 2.3.1.{build} os: WMF 5 install: - ps: . .\AppVeyor\AppVeyorInstall.ps1 @@ -12,20 +12,20 @@ environment: github_access_token: secure: Xk7jTkdE82qskQy9WPZK0zSafSjT6gK1SYxH8m4Aa8muCMQ4ACkkztJ3toh9DFlS ModuleName: cChoco -#---------------------------------# -# build configuration # -#---------------------------------# -build_script: +#---------------------------------# +# build configuration # +#---------------------------------# +build_script: - ps: . .\AppVeyor\AppVeyorBuild.ps1 -#---------------------------------# -# test configuration # -#---------------------------------# -test_script: +#---------------------------------# +# test configuration # +#---------------------------------# +test_script: - ps: . .\AppVeyor\AppVeyorTest.ps1 -#---------------------------------# -# deployment configuration # -#---------------------------------# -deploy_script: - - ps: . .\AppVeyor\AppveyorDeploy.ps1 \ No newline at end of file +#---------------------------------# +# deployment configuration # +#---------------------------------# +deploy_script: + - ps: . .\AppVeyor\AppveyorDeploy.ps1 diff --git a/cChoco.psd1 b/cChoco.psd1 index a0fab28..3e5ceff 100644 --- a/cChoco.psd1 +++ b/cChoco.psd1 @@ -1,12 +1,12 @@ @{ - Copyright = "(c) 2013-2016 Lawrence Gripper, All rights reserved."; - Description = "Module with DSC Resources for using Chocolatey http://chocolatey.org/"; - CompanyName = "Lawrence Gripper"; - GUID = "4857229F-8C2D-41BB-A068-9E3C0C8ED63D"; - PowerShellVersion = "4.0"; - FunctionsToExport = "*"; - CLRVersion = "4.0"; - CmdletsToExport = "*"; - Author = "Lawrence Gripper, Javy de Koning"; - ModuleVersion = "2.3.0.0" + Copyright = "(c) 2017 Chocolatey Software, (c) 2013-2017 Lawrence Gripper, All rights reserved."; + Description = "Chocolatey DSC Resources for use with internal packages and the community package repository. Learn more at http://chocolatey.org/"; + CompanyName = "Chocolatey Software"; + GUID = "4857229F-8C2D-41BB-A068-9E3C0C8ED63D"; + PowerShellVersion = "4.0"; + FunctionsToExport = "*"; + CLRVersion = "4.0"; + CmdletsToExport = "*"; + Author = "Chocolatey Software, Lawrence Gripper, Javy de Koning"; + ModuleVersion = "2.3.1.0" }