From 2d33bbfa8ac9728b6b7ddf782b5e5b5911cbae13 Mon Sep 17 00:00:00 2001 From: dfrancis-adm Date: Fri, 26 Jul 2019 10:52:42 -0400 Subject: [PATCH] Version 0.5.0 --- CHANGELOG.md | 8 +++++ Chocolatey-tools.psd1 | 2 +- functions/Add-ChocoIntPackage.ps1 | 34 ++++++++++++++++++++ functions/Get-ChocoOutdatedPackages.ps1 | 3 +- functions/Get-LatestChocoPackage.ps1 | 34 ++++++++++++++++++++ functions/Invoke-BoxStarterRemoteUpgrade.ps1 | 3 +- functions/Invoke-ChocoInternalizePackage.ps1 | 2 +- functions/Invoke-ChocoRemoteUpgrade.ps1 | 5 +-- functions/Invoke-ChocoUpgradeIntPackage.ps1 | 3 +- functions/Push-ChocoIntPackage.ps1 | 3 +- functions/Test-ChocoUpgradeTrigger.ps1 | 2 +- 11 files changed, 90 insertions(+), 9 deletions(-) create mode 100644 functions/Add-ChocoIntPackage.ps1 create mode 100644 functions/Get-LatestChocoPackage.ps1 diff --git a/CHANGELOG.md b/CHANGELOG.md index a4d8f17..73f312f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,12 @@ # Chocolatey-tools Release History +## 0.4.10 - 7/26/2019 + +### Added +*Get-LatestChocoPackage - retrives latest version of package from community repo. +*Add-ChocoIntPackage - Internalizes, installs and pushes a new package to an internal repo. + +### Fixed +* Put comment-based help in right place in functions. ## 0.4.10 - 7/15/2019 ### Added diff --git a/Chocolatey-tools.psd1 b/Chocolatey-tools.psd1 index 8ace52d..bdd5652 100644 --- a/Chocolatey-tools.psd1 +++ b/Chocolatey-tools.psd1 @@ -12,7 +12,7 @@ RootModule = 'Chocolatey-tools.psm1' # Version number of this module. -ModuleVersion = '0.4.10' +ModuleVersion = '0.5.0' # Supported PSEditions # CompatiblePSEditions = @() diff --git a/functions/Add-ChocoIntPackage.ps1 b/functions/Add-ChocoIntPackage.ps1 new file mode 100644 index 0000000..272ebe5 --- /dev/null +++ b/functions/Add-ChocoIntPackage.ps1 @@ -0,0 +1,34 @@ + +function Add-ChocoIntPackage { +<# + .SYNOPSIS + Internalizes, tests the installation and pushes new Chocolatey packages to a internal repository + .EXAMPLE + Here I internalize the Firefox and Google Chrome packages from the community repo and push to my internal repo. + + Add-ChocoIntPackage -PackageNames firefox,googlechrome -Path C:\Chocotemp\ -RepositoryURL 'https://myrepo/chocolatey' -ApiKey (Get-Credential) + #> + [CmdletBinding()] + param ( + [Parameter(Mandatory=$true,ValueFromPipeline=$True)] + [string[]]$PackageNames, + [Parameter(Mandatory=$true)] + [string]$Path, + [Parameter(Mandatory=$true)] + [string]$RepositoryURL, + [Parameter(Mandatory=$true)] + [ValidateNotNull()] + [System.Management.Automation.PSCredential]$ApiKey + ) + try { + Get-LatestChocoPackage -PackageNames $PackageNames | + Invoke-ChocoInternalizePackage -Path $Path -PurgeWorkingDirectory | + Where-Object { $_.Result -Like 'Internalize Success' } | + Invoke-ChocoUpgradeIntPackage -Path $Path -ErrorAction Stop | + Where-Object {$_.Result -eq 'Upgrade Success'} | + Push-ChocoIntPackage -Path $Path -ApiKey $Apikey -RepositoryURL $RepositoryURL -ErrorAction Stop + } + catch { + $Error[0] | Select-Object -Property Exception,ScriptStackTrace | Format-list + } +} diff --git a/functions/Get-ChocoOutdatedPackages.ps1 b/functions/Get-ChocoOutdatedPackages.ps1 index 943d087..520e0ba 100644 --- a/functions/Get-ChocoOutdatedPackages.ps1 +++ b/functions/Get-ChocoOutdatedPackages.ps1 @@ -1,3 +1,5 @@ + +function Get-ChocoOutdatedPackages { <# .SYNOPSIS Find outdated packages from a local machine @@ -13,7 +15,6 @@ curl 7.64.0 7.64.1 false GoogleChrome 73.0.3683.103 74.0.3729.131 false #> -function Get-ChocoOutdatedPackages { [CmdletBinding()] param( ) diff --git a/functions/Get-LatestChocoPackage.ps1 b/functions/Get-LatestChocoPackage.ps1 new file mode 100644 index 0000000..01cc3eb --- /dev/null +++ b/functions/Get-LatestChocoPackage.ps1 @@ -0,0 +1,34 @@ +function Get-LatestChocoPackage { +<# + .SYNOPSIS + Get the latest version of one or more packages from the Chocolatey community repository. + .EXAMPLE +PS C:\Chocotemp> Get-LatestChocoPackage -PackageName googlechrome,firefox + +Name CurrentVersion Version Pinned +---- -------------- ------- ------ +GoogleChrome 75.0.3770.142 75.0.3770.142 No +Firefox 68.0.1 68.0.1 No + + + #> + [CmdletBinding()] + param ( + [Parameter(Mandatory=$true)] + [string[]]$PackageNames + ) + $PackageNames | ForEach-Object { + $LatestPackage = (choco list $_ --exact --source=chocolatey -r) + if ($LatestPackage){ + [PSCustomObject]@{ + Name = $LatestPackage.Split('|')[0] + CurrentVersion = 'None' + Version = $LatestPackage.Split('|')[1] + Pinned = 'No' + } + } + else { + Write-Error "Could not find latest version of package $_" + } + } +} \ No newline at end of file diff --git a/functions/Invoke-BoxStarterRemoteUpgrade.ps1 b/functions/Invoke-BoxStarterRemoteUpgrade.ps1 index f1c9ede..8e6ea15 100644 --- a/functions/Invoke-BoxStarterRemoteUpgrade.ps1 +++ b/functions/Invoke-BoxStarterRemoteUpgrade.ps1 @@ -1,3 +1,5 @@ + +function Invoke-BoxStarterRemoteUpgrade { <# .SYNOPSIS Uses Install-Boxstarterpackage to install packages remotely. In addition, provides ability to deploy new packages and exclude packages. @@ -13,7 +15,6 @@ Invoke-BoxStarterRemoteUpgrade -ComputerName winclient2 -Credential $DomainCred -AdditionalPackages curl,git -Parallel -ScriptPath C:\Windows\Temp\BoxstarterUpgrade.txt #> -function Invoke-BoxStarterRemoteUpgrade { [CmdletBinding()] param( [Parameter(Mandatory=$true)] diff --git a/functions/Invoke-ChocoInternalizePackage.ps1 b/functions/Invoke-ChocoInternalizePackage.ps1 index 9b241d4..d50dac2 100644 --- a/functions/Invoke-ChocoInternalizePackage.ps1 +++ b/functions/Invoke-ChocoInternalizePackage.ps1 @@ -1,3 +1,4 @@ +function Invoke-ChocoInternalizePackage { <# .SYNOPSIS Takes PSobject as input to internalize packages @@ -14,7 +15,6 @@ curl Internalize Success 7.64.1 C:\Chocotemp\curl.7.64.1.nupkg GoogleChrome Internalize Success 74.0.3729.131 {C:\Chocotemp\chocolatey-core.extension.1.3.3.nupkg, C:\Chocotemp\Googl... #> -function Invoke-ChocoInternalizePackage { [CmdletBinding()] param( [Parameter(Mandatory=$true,ValueFromPipeline=$True)] diff --git a/functions/Invoke-ChocoRemoteUpgrade.ps1 b/functions/Invoke-ChocoRemoteUpgrade.ps1 index 83c26f7..bc15314 100644 --- a/functions/Invoke-ChocoRemoteUpgrade.ps1 +++ b/functions/Invoke-ChocoRemoteUpgrade.ps1 @@ -1,4 +1,6 @@ -<# + +function Invoke-ChocoRemoteUpgrade { + <# .SYNOPSIS Use PowerShell remoting with to remotely update clients by adding and excluding packages. This function uses Invoke-Command to connect and run choco upgrade for any outdated packages. @@ -26,7 +28,6 @@ Computer : WINCLIENT .EXAMPLE Another example of how to use this cmdlet #> -function Invoke-ChocoRemoteUpgrade { [CmdletBinding()] param( [Parameter(Mandatory=$true)] diff --git a/functions/Invoke-ChocoUpgradeIntPackage.ps1 b/functions/Invoke-ChocoUpgradeIntPackage.ps1 index e01ae30..5da5feb 100644 --- a/functions/Invoke-ChocoUpgradeIntPackage.ps1 +++ b/functions/Invoke-ChocoUpgradeIntPackage.ps1 @@ -1,3 +1,5 @@ + +function Invoke-ChocoUpgradeIntPackage { <# .SYNOPSIS Takes PSobject to perform a choco upgrade an each package @@ -14,7 +16,6 @@ curl Upgrade Success 7.64.1 C:\Chocotemp\curl.7.64.1.nupkg GoogleChrome Upgrade Success 74.0.3729.131 {C:\Chocotemp\chocolatey-core.extension.1.3.3.nupkg, C:\Chocotemp\GoogleChr... #> -function Invoke-ChocoUpgradeIntPackage { [CmdletBinding()] param( [Parameter(Mandatory=$true,ValueFromPipeline=$True)] diff --git a/functions/Push-ChocoIntPackage.ps1 b/functions/Push-ChocoIntPackage.ps1 index ebf81d6..d38dcf6 100644 --- a/functions/Push-ChocoIntPackage.ps1 +++ b/functions/Push-ChocoIntPackage.ps1 @@ -1,3 +1,5 @@ + +function Push-ChocoIntPackage { <# .SYNOPSIS Short description @@ -18,7 +20,6 @@ chocolatey-core.extension Push Success 1.3.3 C:\Chocotemp\chocolatey-cor GoogleChrome Push Success 74.0.3729.131 C:\Chocotemp\GoogleChrome.74.0.3729.131.nupkg #> -function Push-ChocoIntPackage { [CmdletBinding()] param( [Parameter(Mandatory=$true,ValueFromPipeline=$True)] diff --git a/functions/Test-ChocoUpgradeTrigger.ps1 b/functions/Test-ChocoUpgradeTrigger.ps1 index 1ed9dd9..e0ca0f8 100644 --- a/functions/Test-ChocoUpgradeTrigger.ps1 +++ b/functions/Test-ChocoUpgradeTrigger.ps1 @@ -1,3 +1,4 @@ + function Test-ChocoUpgradeTrigger { <# .SYNOPSIS Tests each package a PSObject to see if it meets an item in -TriggerPackages. If so, it will create @@ -17,7 +18,6 @@ \ Triggered Choco Upgrade Ready PS C:\Chocotemp> #> - function Test-ChocoUpgradeTrigger { [CmdletBinding()] param( [Parameter(Mandatory=$true,ValueFromPipeline=$True)]