做為一個要開發又要兼顧設備的可憐攻城屍,趕案子同時又要幫其他人設置機器的情景是三天兩頭都會碰到的事情,僅開設VM還好處理,有做過快照以及範本映像檔五分鐘內就可以馬上起一台測試機環境出來。不過若是個人電腦就很麻煩,為確保開發環境乾淨,整台重灌是最保險的方式(老舊的開發環境常有legacy package殘留),流動率越高重灌次數也就越頻繁,確保重灌用的快照不必常常重裝software,找了以下這個工具。
需求
- Windows 7+ / Windows Server 2003+
- PowerShell v2+
- .NET Framework 4+ (如果沒有的話,安裝Chocolatey時會自動安裝)
安裝 Chocolatey
安裝步驟
- 以系統管理員開啟CMD或PowerShell
- 複製下面的指令
- 貼上指令至命令視窗,並按下Enter執行
- 等指令執行完畢
- 沒出現任何錯誤就表示安裝完畢了
Install with cmd.exe
@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
Install with PowerShell.exe
With PowerShell, there is an additional step. You must ensure Get-ExecutionPolicy is not Restricted. We suggest using Bypass to bypass the policy to get things installed or AllSigned for quite a bit more security.
- Run Get-ExecutionPolicy. If it returns Restricted, then run Set-ExecutionPolicy AllSigned or Set-ExecutionPolicy Bypass -Scope Process.
- Now run the following command: (copy command text)
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'))
Additional considerations
NOTE: Please inspect https://chocolatey.org/install.ps1 prior to running any of these scripts to ensure safety. We already know it's safe, but you should verify the security and contents of any script from the internet you are not familiar with. All of these scripts download a remote PowerShell script and execute it on your machine.We take security very seriously. Learn more.
只要執行下列指令,建議第一次安裝都先執行看看
choco upgrade chocolatey
移除 Chocolatey
安裝範例
choco install docker
choco install ruby --version 1.8.7.37402
choco uninstall nodejs.install --all-versions
移除範例
choco uninstall docker notepadplusplus googlechrome
顯示本機安裝過的套件
choco list --local-only
查詢較舊的案件
choco outdated
choco outdated -s https://somewhere/out/there
choco outdated -s "'https://somewhere/protected'" -u user -p pass
留言
張貼留言