Featured image of post Windows10のPackageManagementの使い方【Chocolatey】

Windows10のPackageManagementの使い方【Chocolatey】

Windows10に標準搭載されたパッケージ管理システム「PackageManagement」の使い方。パッケージプロバイダーChocolateyのインストールと初期設定、コマンドでのアプリケーションのインストールまで。Homebrew感覚で管理できます♪

3518文字

Windows10に念願のパッケージ管理システム

パッケージ管理システム?

皆さんはパッケージ管理システムをご存知でしょうか?

パッケージ管理システムといえば、MacだとHomebrew、Linuxだとyumやapt-getが有名ですよね。
Windowsには長らくパッケージ管理システムがありませんでしたが、Windows10以でPackageManagementという名称で標準搭載されるようになりました!

パッケージ管理システムの利点

では、パッケージ管理システムを導入するとどう変わるのか?簡単に説明しましょう。

インストールが簡単

使わない場合
  1. ブラウザを立ち上げる
  2. ブラウザでダウンロードページを探す
  3. ブラウザでダウンロードページを開く
  4. インストーラーをダウンロード
  5. インストーラーを実行
使う場合
  1. ターミナルを立ち上げる
  2. パッケージ管理ツールでインストールコマンドを叩く

アンインストールが簡単

使わない場合
  1. コントロールパネル or 設定画面 を開く
  2. プログラムと機能 or アプリと機能 を開く
  3. アプリを選択し、アプリをアンインストール
使う場合
  1. ターミナルを立ち上げる
  2. パッケージ管理ツールでアンインストールコマンドを叩く

管理が簡単

使わない場合
  1. コントロールパネル or 設定画面 を開く
  2. プログラムと機能 or アプリと機能 を開く
  3. 自分でインストールしたアプリを一覧で把握する
使う場合
  1. ターミナルを立ち上げる
  2. パッケージ管理ツールでインストール済み一覧コマンドを叩く

インストールも簡単

そんな便利なパッケージ管理ツールのインストールは、とても簡単に出来ます。

では、早速インストールをしてみましょう。

手順

パッケージプロバイダーのインストール

パッケージ管理ソフトを利用するには、まずはPowerShellを管理者権限で起動します。

次に以下のコマンドで利用可能なパッケージプロバイダーを見てみましょう。

command
Find-PackageProvider

すると、初回の場合は以下のようなメッセージが表示されると思うので、Yを入力してエンターを押してください。

メッセージ
プロバイダー 'nuget v2.8.5.208' がインストールされていません。
nuget は、https://oneget.org/Microsoft.PackageManagement.NuGetProvider-2.8.5.208.dll
から手動でダウンロードしてインストールすることができます。
PackageManagement で nuget を自動的にダウンロードしてインストールしますか?
[Y] はい(Y)  [N] いいえ(N)  [S] 中断(S)  [?] ヘルプ (既定値は "Y"): Y

すると以下のように利用可能なパッケージプロバイダーが表示されます。

ログ
Name                           Version          Source           Summary
----                           -------          ------           -------
nuget                          2.8.5.208        https://onege... NuGet provider for the OneGet meta-package manager
psl                            1.0.0.210        https://onege... psl provider for the OneGet meta-package manager
chocolatey                     2.8.5.130        https://onege... ChocolateyPrototype provider for the OneGet meta-pa...
PowerShellGet                  1.6.7            PSGallery        PowerShell module with commands for discovering, in...
ChocolateyGet                  1.0.0.1          PSGallery        An PowerShell OneGet provider that discovers packag...
DockerMsftProvider             1.0.0.5          PSGallery        PowerShell module with commands for discovering, in...
NanoServerPackage              1.0.1.0          PSGallery        A PackageManagement provider to  Discover, Save and...
DockerMsftProviderInsider      1.0.0.2          PSGallery        PowerShell module with commands for discovering, in...
GistProvider                   0.6              PSGallery        Gist-as-a-Package - PackageManagement  PowerShell P...
DockerProvider                 0.0.0.3          PSGallery        PowerShell module with commands for discovering, in...
ContainerImage                 0.6.4.0          PSGallery        This is a PackageManagement provider module which h...
GitLabProvider                 1.3.7            PSGallery        GitLab PackageManagement provider
TSDProvider                    0.2              PSGallery        PowerShell PackageManager provider to search & inst...
GitHubProvider                 0.5              PSGallery        GitHub-as-a-Package - PackageManagement PowerShell ...
OfficeProvider                 1.0.0.1          PSGallery        OfficeProvider allows users to install Microsoft Of...
MyAlbum                        0.1.2            PSGallery        MyAlbum provider discovers the photos in your remot...
WSAProvider                    1.0.0.4          PSGallery        Provider to Discover, Install and inventory windows...
AppxGet                        0.1.0.1          PSGallery        Powershell Package Management (OneGet) Provider for...

次に実際にパッケージプロバイダーをインストールします。
今回はchocolateyをインストールしてみます。

command
Get-PackageProvider chocolatey

すると、以下のようなメッセージが表示されるのでYを入力してエンターを押しましょう。

メッセージ
プロバイダー 'chocolatey v2.8.5.130' がインストールされていません。
chocolatey は、https://oneget.org/ChocolateyPrototype-2.8.5.130.exe
から手動でダウンロードしてインストールすることができます。
PackageManagement で chocolatey を自動的にダウンロードしてインストールしますか?
[Y] はい(Y)  [N] いいえ(N)  [S] 中断(S)  [?] ヘルプ (既定値は "Y"): Y

これでパッケージプロバイダーのインストールは完了です。

ログ
Name                     Version          DynamicOptions
----                     -------          --------------
Chocolatey               2.8.5.130        SkipDependencies, ContinueOnFailure, ExcludeVersion, ForceX86, PackageSave...

初期設定

では、次にChocolateyの初期設定を行いましょう。
こちらの設定をしておかないと正常にインストール出来ません。

以下のコマンドを実行してください。

command
Set-ExecutionPolicy RemoteSigned

以下のようなメッセージが表示されるので、Yを入力しエンターを押してください。

メッセージ
実行ポリシーの変更
実行ポリシーは、信頼されていないスクリプトからの保護に役立ちます。実行ポリシーを変更すると、about_Execution_Policies
のヘルプ トピック (https://go.microsoft.com/fwlink/?LinkID=135170)
で説明されているセキュリティ上の危険にさらされる可能性があります。実行ポリシーを変更しますか?
[Y] はい(Y)  [A] すべて続行(A)  [N] いいえ(N)  [L] すべて無視(L)  [S] 中断(S)  [?] ヘルプ (既定値は "N"): Y

何も表示されなければ初期設定は完了です。

アプリケーションのインストール

では、実際にアプリケーションをインストールしてみましょう。
今回はGoogleChromeをインストールしてみましょう。

まずは以下のコマンドでChromeがあるか確認してみましょう。

command
Find-Package chrome

すると以下のように大量にヒットしますが、とりあえず一番最初に表示されているGoogleChromeをインストールしましょう。

ログ
Name                           Version          Source           Summary
----                           -------          ------           -------
GoogleChrome                   68.0.3440.10600  chocolatey       Chrome is a fast, simple, and secure web browser, b...
google-chrome-x64              47.0.2526.81     chocolatey       Deprecated. Install [GoogleChrome](/packages/Google...
adblockpluschrome              1.12.4           chocolatey       Chrome extension that blocks advertising while you ...
selenium-chrome-driver         2.41             chocolatey       Chrome Driver is a WebDriver implementation that en...
GoogleChrome-AllUsers          26.0.1410.64     chocolatey       Google Chrome Offline Installer- for all users
chromedriver                   2.410            chocolatey       Downloads and installs Chromedriver.exe from http:/...
https-everywhere-chrome        2016.12.19       chocolatey       Automatically use HTTPS security on many sites.
GoogleChrome.Canary            28.0.1461.0      chocolatey       Google Chrome Canary has the newest of the new Chro...
ChromeDriver2                  2.25             chocolatey       ChromeDriver is a webdriver server for chrome
GoogleChrome.Dev               27.0.1453.12     chocolatey       Google Chrome Dev is released once or twice a week ...
chromepass                     1.45             chocolatey       Chrome Browser Password Recovery
google-hangouts-chrome         2017.110.418.20  chocolatey       Google Hangouts Chrome Extension
EthanBrown.ChromeDevExtensions 0.0.2            chocolatey       Chrome extensions for web development.
EthanBrown.ChromeCanaryDevE... 0.0.2            chocolatey       Chrome Canary extensions for web development.
chromecookiesview              1.46             chocolatey       View/delete cookies of Chrome Web browser
chromecacheview                1.70             chocolatey       Cache viewer for Google Chrome Web browser
plex-chrome                    2.12.8.002018... chocolatey       Plex Chrome extension
ipwhoisflags-chrome            3.42.20170115    chocolatey       IP Whois and Flags Chrome extension
skype-chrome                   8.5.0.91671      chocolatey       Skpye Chrome extension
chrome-remote-desktop-chrome   63.0.3239.17     chocolatey       Chrome Remote Desktop application
speedtest-chrome               1.0.7.20170115   chocolatey       Speedtest by Ooka Chrome extension
trello-chrome                  0.0.48.20170115  chocolatey       Trello extension for Chrome
ietab-chrome                   10.1.11.1        chocolatey       IE Tab for Chrome extension
choco-chrome-ext               1.0.0.8          chocolatey       This is an unofficial Chocolatey Extension for Goog...
google-voice-chrome            2.4.4.20170115   chocolatey       Google Voice Chrome extension
evernote-chrome                6.10.3           chocolatey       Evernote Chrome extension
pushbullet-chrome              336.0.20170115   chocolatey       Pushbullet Chrome extension
feedly-chrome                  35.0.20170115    chocolatey       feedly Chrome extension
chromehistoryview              1.32             chocolatey       View the browsing history of Chrome Web browser
checkerplusforgmail-chrome     19.3.8           chocolatey       Checker Plus for Gmail Chrome extension
amazon-assistant-chrome        10.1610.8.1201   chocolatey       Amazon Assistant Chrome extension
chromelpass-chrome             2.8.1            chocolatey       KeePass integration for Chrome using KeePassHttp
save-to-pocket-chrome          2.1.17           chocolatey       Save to Pocket Chrome Extension
ebay-chrome                    4.2.25           chocolatey       eBay Chrome extension
momentum-chrome                0.92.2           chocolatey       Momentum Chrome extension
office-online-chrome           1.5.0.20170115   chocolatey       Microsoft Office Online Chrome extension
gsuite-training-chrome         1.8.11           chocolatey       G Suite Training for Chrome extension
quick-javascript-switcher-c... 1.4.1.20170115   chocolatey       Quick way to enable/disable Javascript in Chrome
mini-squeezebox-control-chrome 1.2.20170115     chocolatey       Mini Squeezebox Control Chrome extension.
google-cast-chrome             15.1120.0.4      chocolatey       ![Screenshot of Google Cast for Chrome](https://lh6...
mightytext-chrome              19.6.20170115    chocolatey       MightyText - SMS from PC and Text from Computer
addtoany-chrome                3.0.4            chocolatey       Chrome extension to add share options to MANY popul...
lastpass-chrome                4.3.0            chocolatey       LastPass remembers all your passwords, so you don't...
wot-chrome                     3.2.1            chocolatey       The official Web of Trust Chrome Extension.
google-chrome-for-enterprise   67.0.3396.87     chocolatey       Google Chrome for Enterprise
gsuite-new-tab-chrome          1.5.3            chocolatey       Chrome new tab replacement for G Suite users.
amazon-music-chrome            1.4              chocolatey       ![Screenshot of Amazon Music for Chrome](https://lh...
utorrent-easy-client-chrome    2.6.8            chocolatey       uTorrent easy client allows you to monitor and cont...
desktop-notifications-for-a... 4.5.2            chocolatey       Receive Android notifications on your desktop
open-screenshot-chrome         24.0             chocolatey       ![Screenshot of Open Screenshot](https://lh3.google...
vnc-viewer-chrome              1.2.2.15132      chocolatey       ###Connects to your computers anywhere in the world...
back-to-backspace-chrome       1.3.0            chocolatey       This Chrome extension re-enables the backspace key ...
slickrss-chrome                2.993            chocolatey       Slick RSS is a RSS reader that works inside of Chrome.
googlechrome-authy             2.3.0            chocolatey       Authy for PC's makes Two-Factor Authentication a tr...
tineye-chrome                  1.1.5            chocolatey       TinEye for Chrome lets you search for other instanc...
googlechrome-zenhub            1.0.0            chocolatey       Build your team's ultimate GitHub workflow.
utorrent-link-sender-chrome    0.0.9            chocolatey       uTorrent Link Sender adds a context menu selection ...
chromehue-chrome               1.1.6            chocolatey       A Chrome extention to control your Phillips Hue lig...
reveye-chrome                  1.4.4            chocolatey       Right click an image to search for it on Google, Bi...
chromecookiebackup             1.0.0            chocolatey       A Windows Tool for backing up and restoring Chrome'...
googlechrome-github-expandi... 1.0.0            chocolatey       Chrome extension that improves the GitHub experience.
genius-chrome                  0.1.2            chocolatey       Genius lets you add line-by-line annotations to any...
teamviewer-chrome              13.0.281         chocolatey       TeamViewer Chrome app.
save-to-tonido-chrome          1.1.0            chocolatey       Save to Tonido allows you to save documents to your...
google-calendar-chrome         2.8              chocolatey       Easily check Google Calendar and add new events fro...
trafficlight-chrome            1.1.0.9          chocolatey       Bitdefender TrafficLight - Cutting edge browser pro...
grammarly-chrome               14.821.1.1383    chocolatey       Grammarly leaves outdated spelling and grammar chec...
earthview-chrome               2.18.5           chocolatey       Earth View from Google Earth - Experience a beautif...
chrometana-chrome              2.0.1            chocolatey       Chrometana lets your redirect Bing to the search en...
save-to-google-drive-chrome    2.1.1            chocolatey       Save web content or screen capture directly to Goog...
google-translate-chrome        2.0.7            chocolatey       Google Translate - View translations easily as you ...
google-dictionary-chrome       4.0.8            chocolatey       Google Dictionary - View definitions easily as you ...
keep-chrome                    3.1.16302.1110   chocolatey       Google Keep Chrome Extension
mybrowserpage-chrome           1.0              chocolatey       MyBrowserPage is a starterpage with Metro design.
weather-chrome                 4.2.97           chocolatey       Weather extension for Chrome - The best way to see ...
fireshot-chrome                0.98.93.2        chocolatey       The FireShot Chrome extension takes full web page s...
waybackmachine-chrome          2.12             chocolatey       Wayback Machine is a Chrome extension to check Inte...
inbox-chrome                   1.0.0.1929       chocolatey       Inbox by Gmail - Save links to web pages for later ...
search-by-image-chrome         1.5.2            chocolatey       Search by Image (by Google) - This extension allows...
data-saver-chrome              2.0.2            chocolatey       Data Saver for Chrome reduces data usage by using G...
logiccards-chrome              1.0.0.2          chocolatey       The LogicCards Chrome extension provides dynamic no...
exifviewer-chrome              2.4.4            chocolatey       EXIF Viewer is a Chrome extension that allows you t...
github-hovercard-chrome        1.4.4            chocolatey       Neat hovercards for GitHub.
secureshell-chrome             0.8.43           chocolatey       Secure Shell (nassh) is a Chrome App that combines ...
notifier-for-github-chrome     3.0.5            chocolatey       Notifier for GitHub displays your GitHub notificati...
chrome-remote-desktop-host     1.0              chocolatey       Chrome Remote Desktop Host
mosh-for-chrome                0.4.5            chocolatey       Remote terminal application
google-play-music-chrome       1.390.0          chocolatey       Google Play Music for Chrome is a free app that add...
dropbox-for-gmail-chrome       1.1.6            chocolatey       Send and preview Dropbox files and links without le...
windows-defender-browser-pr... 1.62             chocolatey       Windows Defender Browser Protection - Protect yours...
toby-chrome                    0.5.2            chocolatey       Toby is a Chrome extension that organizes bookmarks...
passprotect-chrome             0.1.8            chocolatey       PassProtect is a simple Chrome extension that drama...
justread-chrome                1.1.12           chocolatey       Just Read - The extension makes it easy to view web...
boomeranggmail-chrome          1.2.7            chocolatey       Boomerang for Gmail - The ultimate email productivi...
burneremails-chrome            0.1.7            chocolatey       Burner Emails: Easy, Fast, Disposable Emails
chrono-chrome                  0.10.0           chocolatey       Chrono Download Manager - Download and manage the Web!
news-feed-eradicator-for-fa... 1.0.6            chocolatey       News Feed Eradicator helps you cut out the crap and...

では、以下のコマンドで実際に以下のコマンドでインストールしましょう。

command
Install-Package GoogleChrome

また似たようなメッセージが表示されるので、Yを入力してエンターを押しましょう。

メッセージ
パッケージは、信頼済みとマークされていないパッケージ ソースから取得されています。
'chocolatey' からソフトウェアをアンインストールしますか?
[Y] はい(Y)  [A] すべて続行(A)  [N] いいえ(N)  [L] すべて無視(L)  [S] 中断(S)  [?] ヘルプ (既定値は "N"): Y

以下のログが表示されればインストールは完了です。

ログ
Name                           Version          Source           Summary
----                           -------          ------           -------
chocolatey-core.extension      1.3.3            chocolatey       Helper functions extending core choco functionality
GoogleChrome                   68.0.3440.10600  chocolatey       Chrome is a fast, simple, and secure web browser, b...

確認

では、確認してみましょう。

正常にChromeが起動しましたね♪

終わりに

以上のように、簡単にWindowsマシンのアプリケーションのインストールから管理が出来るようになります。

インストーラーを使う必要が無くなるので、マシンが汚れることが無くなるのでWindows10ユーザーの方は是非使ってみてください♪