Chocolatey

De Banane Atomic
Aller à la navigationAller à la recherche

Informations

Chocolatey est un gestionnaire de paquets pour Windows.

  • Les paquets sont installés dans C:\ProgramData\chocolatey
  • Les installers sont téléchargés dans %Temp%\chocolatey
  • log dans C:\ProgramData\chocolatey\logs\chocolatey.log

CLI

Lancer le terminal en mode administrateur pour les opérations d'installation.
Ps.svg
# recherche d'un package
choco search <Package_Name>

# installation
choco install <Package_Name>
# --version x.x

# désinstallation
choco uninstall <Package_Name>
# -a all version
# -x uninstall dependencies

# lister les paquets locaux
choco list -l

Upgrade

Ps.svg
# list outdated packages
choco outdated

# tous mettre à jour
choco upgrade all

# tous mettre à jour sauf un package
choco upgrade all --except=<Package_Name>

# mise à jour d'un package
choco upgrade <Package_Name>

# pin / unpin a package so it will stay in the current version
choco pin add -n <Package_Name>
choco pin add --name="'<Package_Name>'" --version="'<Package_Version>'"
choco pin remove -n <Package_Name>

# list the pin packages
choco pin list

Downgrade

Ps.svg
choco install <Package_Name> --version=1.2.3 --allow-downgrade
# --force

Clean

Ps.svg
# install choco-cleaner
choco install choco-cleaner

# run
choco-cleaner

Installation

Ps.svg
# dans une console administrateur
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))

# mise à jour
choco upgrade chocolatey
%UserProfile%\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
# Chocolatey profile
$ChocolateyProfile = "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1"
if (Test-Path($ChocolateyProfile)) {
  Import-Module "$ChocolateyProfile"
}
Function.ps1
New-Alias cs choco-search
New-Alias ci choco-install
New-Alias cu choco-upgrade
New-Alias cl choco-list

function choco-search {
    choco search $args
}
function choco-install {
    #Start-Process powershell.exe -Verb RunAs 'choco install -y $args'
    choco install -y $args
}
function choco-upgrade {
    #Start-Process powershell.exe -Verb RunAs 'choco upgrade all'
    choco upgrade all
}
function choco-list {
    choco list -l
}