Version 0.5.0
This commit is contained in:
34
functions/Add-ChocoIntPackage.ps1
Normal file
34
functions/Add-ChocoIntPackage.ps1
Normal file
@@ -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
|
||||
}
|
||||
}
|
||||
@@ -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(
|
||||
)
|
||||
|
||||
34
functions/Get-LatestChocoPackage.ps1
Normal file
34
functions/Get-LatestChocoPackage.ps1
Normal file
@@ -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 $_"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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)]
|
||||
|
||||
@@ -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)]
|
||||
|
||||
@@ -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)]
|
||||
|
||||
@@ -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)]
|
||||
|
||||
@@ -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)]
|
||||
|
||||
@@ -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)]
|
||||
|
||||
Reference in New Issue
Block a user