diff --git a/CHANGELOG.md b/CHANGELOG.md index bd53a39..9cac080 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Modified project with new Sampler template. - Invoking choco commands now always add `--no-progress` & `--limit-output`. -- Limiting Get-Command choco to the first result as per [#69](https://github.com/chocolatey-community/Chocolatey/issues/69). +- Limiting Get-Command choco to the first result as per [#69](https://github.com/chocolatey-community/Chocolatey/issues/69) on all calls. - Changed `ChocolateySoftware` to be class-based DSC Resource. - Changed `ChocolateyPackage` to be class-based DSC Resource. - Changed `ChocolateySource` to be a class-based DSC Resource. diff --git a/source/Classes/002.ChocolateyPackage.ps1 b/source/Classes/002.ChocolateyPackage.ps1 index e367ec8..207ae00 100644 --- a/source/Classes/002.ChocolateyPackage.ps1 +++ b/source/Classes/002.ChocolateyPackage.ps1 @@ -220,7 +220,7 @@ class ChocolateyPackage 'BelowExpectedVersion$' { Write-Debug -Message ('Upgrading package ''{0}'' to version ''{1}''.' -f $this.Name, $this.Version) - $chocoCommand = Get-Command -Name 'Update-ChocolateyPackage' -Module 'Chocolatey' + $chocoCommand = Get-Command -Name 'Update-ChocolateyPackage' -Module 'Chocolatey' } 'ShouldBeInstalled$' diff --git a/source/Classes/003.ChocolateySoftware.ps1 b/source/Classes/003.ChocolateySoftware.ps1 index 6b3c545..8451757 100644 --- a/source/Classes/003.ChocolateySoftware.ps1 +++ b/source/Classes/003.ChocolateySoftware.ps1 @@ -72,7 +72,7 @@ class ChocolateySoftware [ChocolateySoftware] Get() { $currentState = [ChocolateySoftware]::new() - $chocoExe = Get-Command -Name 'choco.exe' -ErrorAction 'Ignore' + $chocoExe = @(Get-Command -Name 'choco.exe' -ErrorAction 'Ignore')[0] if ($null -eq $chocoExe) { diff --git a/source/public/Add-ChocolateyPin.ps1 b/source/public/Add-ChocolateyPin.ps1 index 776ced5..3982d7b 100644 --- a/source/public/Add-ChocolateyPin.ps1 +++ b/source/public/Add-ChocolateyPin.ps1 @@ -48,7 +48,7 @@ function Add-ChocolateyPin process { - if (-not ($chocoCmd = Get-Command 'choco.exe' -CommandType Application -ErrorAction SilentlyContinue)) + if (-not ($chocoCmd = @(Get-Command 'choco.exe' -CommandType 'Application' -ErrorAction 'SilentlyContinue')[0])) { throw "Chocolatey Software not found." } diff --git a/source/public/Disable-ChocolateyFeature.ps1 b/source/public/Disable-ChocolateyFeature.ps1 index 2070a63..42fbd5d 100644 --- a/source/public/Disable-ChocolateyFeature.ps1 +++ b/source/public/Disable-ChocolateyFeature.ps1 @@ -39,7 +39,7 @@ function Disable-ChocolateyFeature process { - if (-not ($chocoCmd = Get-Command 'choco.exe' -CommandType Application -ErrorAction SilentlyContinue)) + if (-not ($chocoCmd = @(Get-Command 'choco.exe' -CommandType 'Application' -ErrorAction 'SilentlyContinue')[0])) { throw "Chocolatey Software not found." } diff --git a/source/public/Disable-ChocolateySource.ps1 b/source/public/Disable-ChocolateySource.ps1 index 6278eb7..4bed613 100644 --- a/source/public/Disable-ChocolateySource.ps1 +++ b/source/public/Disable-ChocolateySource.ps1 @@ -39,7 +39,7 @@ function Disable-ChocolateySource process { - if (-not ($chocoCmd = Get-Command 'choco.exe' -CommandType Application -ErrorAction SilentlyContinue)) + if (-not ($chocoCmd = @(Get-Command 'choco.exe' -CommandType 'Application' -ErrorAction 'SilentlyContinue')[0])) { throw "Chocolatey Software not found." } diff --git a/source/public/Enable-ChocolateyFeature.ps1 b/source/public/Enable-ChocolateyFeature.ps1 index f312b98..86d8cf6 100644 --- a/source/public/Enable-ChocolateyFeature.ps1 +++ b/source/public/Enable-ChocolateyFeature.ps1 @@ -39,7 +39,7 @@ function Enable-ChocolateyFeature process { - if (-not ($chocoCmd = Get-Command 'choco.exe' -CommandType Application -ErrorAction SilentlyContinue)) + if (-not ($chocoCmd = @(Get-Command 'choco.exe' -CommandType 'Application' -ErrorAction 'SilentlyContinue')[0])) { throw "Chocolatey Software not found." } diff --git a/source/public/Enable-ChocolateySource.ps1 b/source/public/Enable-ChocolateySource.ps1 index 89f6622..f4aeee3 100644 --- a/source/public/Enable-ChocolateySource.ps1 +++ b/source/public/Enable-ChocolateySource.ps1 @@ -40,7 +40,7 @@ function Enable-ChocolateySource process { - if (-not ($chocoCmd = Get-Command 'choco.exe' -CommandType Application -ErrorAction SilentlyContinue)) + if (-not ($chocoCmd = @(Get-Command 'choco.exe' -CommandType 'Application' -ErrorAction 'SilentlyContinue')[0])) { throw "Chocolatey Software not found." } diff --git a/source/public/Get-ChocolateyFeature.ps1 b/source/public/Get-ChocolateyFeature.ps1 index 0c09145..c5145d8 100644 --- a/source/public/Get-ChocolateyFeature.ps1 +++ b/source/public/Get-ChocolateyFeature.ps1 @@ -33,7 +33,7 @@ function Get-ChocolateyFeature ) begin { - if (-not ($chocoCmd = Get-Command 'choco.exe' -CommandType Application -ErrorAction SilentlyContinue)) + if (-not ($chocoCmd = @(Get-Command 'choco.exe' -CommandType 'Application' -ErrorAction 'SilentlyContinue')[0])) { throw "Chocolatey Software not found." } diff --git a/source/public/Get-ChocolateyPackage.ps1 b/source/public/Get-ChocolateyPackage.ps1 index 398502b..2b837cc 100644 --- a/source/public/Get-ChocolateyPackage.ps1 +++ b/source/public/Get-ChocolateyPackage.ps1 @@ -119,7 +119,7 @@ function Get-ChocolateyPackage process { - if (-not ($chocoCmd = Get-Command 'choco.exe' -CommandType 'Application' -ErrorAction 'SilentlyContinue')) + if (-not ($chocoCmd = @(Get-Command 'choco.exe' -CommandType 'Application' -ErrorAction 'SilentlyContinue')[0])) { throw "Chocolatey Software not found." } diff --git a/source/public/Get-ChocolateyPin.ps1 b/source/public/Get-ChocolateyPin.ps1 index a007a6a..f42b8f7 100644 --- a/source/public/Get-ChocolateyPin.ps1 +++ b/source/public/Get-ChocolateyPin.ps1 @@ -29,7 +29,7 @@ function Get-ChocolateyPin process { - if (-not ($chocoCmd = Get-Command 'choco.exe' -CommandType Application -ErrorAction SilentlyContinue)) + if (-not ($chocoCmd = @(Get-Command 'choco.exe' -CommandType 'Application' -ErrorAction 'SilentlyContinue')[0])) { throw "Chocolatey Software not found." } diff --git a/source/public/Get-ChocolateySetting.ps1 b/source/public/Get-ChocolateySetting.ps1 index c244919..68b0a84 100644 --- a/source/public/Get-ChocolateySetting.ps1 +++ b/source/public/Get-ChocolateySetting.ps1 @@ -32,7 +32,7 @@ function Get-ChocolateySetting ) begin { - if (-not ($chocoCmd = Get-Command 'choco.exe' -CommandType Application -ErrorAction SilentlyContinue)) + if (-not ($chocoCmd = @(Get-Command 'choco.exe' -CommandType 'Application' -ErrorAction 'SilentlyContinue')[0])) { throw "Chocolatey Software not found." } diff --git a/source/public/Get-ChocolateySource.ps1 b/source/public/Get-ChocolateySource.ps1 index d3cb279..a32cc18 100644 --- a/source/public/Get-ChocolateySource.ps1 +++ b/source/public/Get-ChocolateySource.ps1 @@ -35,7 +35,7 @@ function Get-ChocolateySource ) begin { - if (-not ($chocoCmd = Get-Command 'choco.exe' -CommandType Application -ErrorAction SilentlyContinue)) + if (-not ($chocoCmd = @(Get-Command 'choco.exe' -CommandType 'Application' -ErrorAction 'SilentlyContinue')[0])) { throw "Chocolatey Software not found." } diff --git a/source/public/Get-ChocolateyVersion.ps1 b/source/public/Get-ChocolateyVersion.ps1 index f358a49..f9bbc7d 100644 --- a/source/public/Get-ChocolateyVersion.ps1 +++ b/source/public/Get-ChocolateyVersion.ps1 @@ -19,7 +19,7 @@ function Get-ChocolateyVersion param ( ) - if (-not ($chocoCmd = Get-Command 'choco.exe' -CommandType Application -ErrorAction SilentlyContinue)) + if (-not ($chocoCmd = @(Get-Command 'choco.exe' -CommandType 'Application' -ErrorAction 'SilentlyContinue')[0])) { throw "Chocolatey Software not found." } diff --git a/source/public/Register-ChocolateySource.ps1 b/source/public/Register-ChocolateySource.ps1 index 337471b..d384366 100644 --- a/source/public/Register-ChocolateySource.ps1 +++ b/source/public/Register-ChocolateySource.ps1 @@ -127,7 +127,7 @@ function Register-ChocolateySource process { - if (-not ($chocoCmd = Get-Command 'choco.exe' -CommandType Application -ErrorAction SilentlyContinue)) + if (-not ($chocoCmd = @(Get-Command 'choco.exe' -CommandType 'Application' -ErrorAction 'SilentlyContinue')[0])) { throw "Chocolatey Software not found." } diff --git a/source/public/Remove-ChocolateyPin.ps1 b/source/public/Remove-ChocolateyPin.ps1 index ce118f0..a19ac15 100644 --- a/source/public/Remove-ChocolateyPin.ps1 +++ b/source/public/Remove-ChocolateyPin.ps1 @@ -33,7 +33,7 @@ function Remove-ChocolateyPin process { - if (-not ($chocoCmd = Get-Command 'choco.exe' -CommandType Application -ErrorAction SilentlyContinue)) + if (-not ($chocoCmd = @(Get-Command 'choco.exe' -CommandType 'Application' -ErrorAction 'SilentlyContinue')[0])) { throw "Chocolatey Software not found." } diff --git a/source/public/Set-ChocolateySetting.ps1 b/source/public/Set-ChocolateySetting.ps1 index 0eb1de8..38f8730 100644 --- a/source/public/Set-ChocolateySetting.ps1 +++ b/source/public/Set-ChocolateySetting.ps1 @@ -65,7 +65,7 @@ function Set-ChocolateySetting process { - if (-not ($chocoCmd = Get-Command 'choco.exe' -CommandType Application -ErrorAction SilentlyContinue)) + if (-not ($chocoCmd = @(Get-Command 'choco.exe' -CommandType 'Application' -ErrorAction 'SilentlyContinue')[0])) { throw "Chocolatey Software not found." } diff --git a/source/public/Test-ChocolateyInstall.ps1 b/source/public/Test-ChocolateyInstall.ps1 index 036e20a..1adba22 100644 --- a/source/public/Test-ChocolateyInstall.ps1 +++ b/source/public/Test-ChocolateyInstall.ps1 @@ -37,7 +37,7 @@ function Test-ChocolateyInstall $InstallDir = (Resolve-Path $InstallDir -ErrorAction Stop).Path } - if ($chocoCmd = get-command choco.exe -CommandType Application -ErrorAction SilentlyContinue) + if (-not ($chocoCmd = @(Get-Command 'choco.exe' -CommandType 'Application' -ErrorAction 'SilentlyContinue')[0])) { if ( !$InstallDir -or diff --git a/source/public/Uninstall-Chocolatey.ps1 b/source/public/Uninstall-Chocolatey.ps1 index 36710c2..134e39a 100644 --- a/source/public/Uninstall-Chocolatey.ps1 +++ b/source/public/Uninstall-Chocolatey.ps1 @@ -45,11 +45,11 @@ function Uninstall-Chocolatey if (-not $InstallDir) { Write-Debug -Message "Attempting to find the choco.exe command." - $chocoCmd = Get-Command -Name 'choco.exe' -CommandType 'Application' -ErrorAction 'SilentlyContinue' + $chocoCmd = @(Get-Command 'choco.exe' -CommandType 'Application' -ErrorAction 'SilentlyContinue')[0] #Install dir is where choco.exe is found minus \bin subfolder if (-not ($chocoCmd -and ($chocoBin = Split-Path -Parent $chocoCmd.Path -ErrorAction SilentlyContinue))) { - Write-Warning "Could not find Chocolatey Software Install Folder." + Write-Warning -Message "Could not find Chocolatey Software Install Folder." return } else diff --git a/source/public/Unregister-ChocolateySource.ps1 b/source/public/Unregister-ChocolateySource.ps1 index 52e7d55..f0ae036 100644 --- a/source/public/Unregister-ChocolateySource.ps1 +++ b/source/public/Unregister-ChocolateySource.ps1 @@ -132,7 +132,7 @@ function Unregister-ChocolateySource process { - if (-not ($chocoCmd = Get-Command 'choco.exe' -CommandType Application -ErrorAction SilentlyContinue)) + if (-not ($chocoCmd = @(Get-Command 'choco.exe' -CommandType 'Application' -ErrorAction 'SilentlyContinue')[0])) { throw "Chocolatey Software not found." }