2025年3月21日 星期五

[研究]用PowerShell安裝Chocolatey 2.4.3 (Windows Server 2019)

[研究]用PowerShell安裝Chocolatey 2.4.3 (Windows Server 2019)

2025-03-21

Chocolatey 是一款適用於 Windows 的包管理器,它能夠讓使用者通過命令行輕鬆安裝、升級、配置及卸載軟體。與 Linux 系統中的包管理器(如 apt 或 yum)類似,Chocolatey 使得 Windows 使用者能夠快速管理軟體安裝,並且能夠從一個中心位置來進行管理,避免手動下載安裝檔案。

使用者只需透過簡單的命令,如 choco install <軟體名稱>,便可安裝指定的軟體。Chocolatey 支援大量常見的應用程式,並且會自動處理安裝過程中的依賴性,讓管理軟體變得更加方便。

它還支援自動化安裝流程,適合開發者和系統管理員進行批量安裝或自動化配置。

Chocolatey => 巧克力口味

官方網站
https://chocolatey.org/

Open Source, Pro, Business 版本比較
https://chocolatey.org/compare

Chocolatey是一個Windows下的軟體套件管理器,讓使用者可以像在類Unix系統中使用Yum和APT一樣使用它,在Windows中實現自動化輕鬆管理Windows軟體的所有方面(安裝,組態,升級和解除安裝)。
https://zh.wikipedia.org/zh-tw/Chocolatey

安裝

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'))






PS C:\> Set-ExecutionPolicy Bypass -Scope Process -Force;
PS C:\> [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072;
PS C:\> 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.
Downloading https://community.chocolatey.org/api/v2/package/chocolatey/2.4.3 to C:\Users\ADMINI~1\AppData\Local\Temp\chocolatey\chocoInstall\chocolatey.zip
Not using proxy.
Extracting C:\Users\ADMINI~1\AppData\Local\Temp\chocolatey\chocoInstall\chocolatey.zip to C:\Users\ADMINI~1\AppData\Local\Temp\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\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\ndp48-x86-x64-allos-enu.exe' - this may take awhile with no output.
警告: .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...
警告: 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:\> choco -v
2.4.3
PS C:\>



(完)

相關




沒有留言:

張貼留言