Instal·lació de Chocolatey a les MVs Windows
Per instal·lar Chocolatey, creiem convenient instal·lar-ho a les mv servidor i també a les màquines clients. Per fer-ho, utilitzaré el PowerShell.
Get-ExecutionPolicy Comprovem que permet executar script.
Set-ExecutionPolicy Bypass -Scope Process -Force Si retorna “Restricted”, ho canviem temporalment.
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')) Executem.
choco -v Comprovem la versió, si aquesta comanda no la reconeix, podem revisar directament el directori.
C:\ProgramData\chocolatey Comprovació d'instal·lació
PS C:\Users\Administrator> 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')) Forcing web requests to allow TLS v1.2 (Required for requests to Chocolatey.org) Getting latest version of the Chocolatey package for download. Not using proxy. Getting Chocolatey from https://community.chocolatey.org/api/v2/package/chocolatey/2.5.1. Downloading https://community.chocolatey.org/api/v2/package/chocolatey/2.5.1 to C:\Users\ADMINI~1\AppData\Local\Temp\1\chocolatey\chocoInstall\chocolatey.zip Not using proxy. Extracting C:\Users\ADMINI~1\AppData\Local\Temp\1\chocolatey\chocoInstall\chocolatey.zip to C:\Users\ADMINI~1\AppData\Local\Temp\1\chocolatey\chocoInstall Installing Chocolatey on the local machine The registry key for .Net 4.8 was not found or this is forced Downloading 'https://download.visualstudio.microsoft.com/download/pr/2d6bb6b2-226a-4baa-bdec-798822606ff1/8494001c276a4b96804cde7829c04d7f/ndp48-x86-x64-allos-enu.exe' to 'C:\Users\ADMINI~1\AppData\Local\Temp\1\ndp48-x86-x64-allos-enu.exe' - the installer is 100+ MBs, so this could take a while on a slow connection. Installing 'C:\Users\ADMINI~1\AppData\Local\Temp\1\ndp48-x86-x64-allos-enu.exe' - this may take awhile with no output. WARNING: .NET Framework 4.8 was installed, but a reboot is required before using Chocolatey CLI. Creating ChocolateyInstall as an environment variable (targeting 'Machine') Setting ChocolateyInstall to 'C:\ProgramData\chocolatey' WARNING: It's very likely you will need to close and reopen your shell before you can use choco. Restricting write permissions to Administrators We are setting up the Chocolatey package repository. The packages themselves go to 'C:\ProgramData\chocolatey\lib' (i.e. C:\ProgramData\chocolatey\lib\yourPackageName). A shim file for the command line goes to 'C:\ProgramData\chocolatey\bin' and points to an executable in 'C:\ProgramData\chocolatey\lib\yourPackageName'. Creating Chocolatey CLI folders if they do not already exist. chocolatey.nupkg file not installed in lib. Attempting to locate it from bootstrapper. PATH environment variable does not have C:\ProgramData\chocolatey\bin in it. Adding... WARNING: Not setting tab completion: Profile file does not exist at 'C:\Users\Administrator\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1'. Chocolatey CLI (choco.exe) is nearly ready. You need to restart this machine prior to using choco. Ensuring Chocolatey commands are on the path Ensuring chocolatey.nupkg is in the lib folder PS C:\Users\Administrator>
Pasos per esborrar Chocolatey
Per esborrar el Choclatey simplement posem la comanda que veiem a sota i després comprovem que no troba la ruta on s’ha instal·lat confirmant que ha sigut esborrat.
PS C:\Users\Administrator> Remove-Item -Recurse -Force
C:\ProgramData\chocolatey
PS C:\Users\Administrator>
C:\ProgramData\chocolatey\bin
C:\ProgramData\chocolatey\bin :
The term '
C:\ProgramData\chocolatey\bin' is
not recognized as the name of a
cmdlet, function, script file, or
operable program. Check the
spelling of the name, or if a
path was included, verify that
the path is correct and try agai
n. At line:1
char:1
+ C:\ProgramData\chocolatey\bin
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo :
ObjectNotFound: (
C:\ProgramData\chocolatey\bi
n:String) [],
CommandNotFoundException
+ FullyQualifiedErrorId :
CommandNotFoundException
PS C:\Users\Administrator>