LoginSignup
45
51

More than 5 years have passed since last update.

Windows7でもPackageManagement(OneGet)

Last updated at Posted at 2015-07-02

Windows10にはPowershell 5.0が標準装備でPackageManagementも標準装備でした。
なのでPowershell上から、さらっと使ってソフトをインストールすることができます。

例えば

find-package
PS > Find-Package -Name LibreOffice

install-package
# インストールは管理者権限で実行すること
PS > Install-Package -Name LibreOffice

めちゃくちゃ便利!

Windows7をお守りしなければならない情シスの性、
この便利なPackage ManagementをWindows7で使えないだろうか?

Windows Management Framework 5.1をインストールすれば使える

  1. .Net Framework 4.6 Install
  2. Windows Management Framework 5.1 Install
  3. PowerShell上でSet-ExecutionPolicy RemoteSigned

これだけで使えるようになります。

実際に入っているか確認してみましょう。

確認
PS > Get-Command -Module PackageManagement

CommandType     Name                        ModuleName
-----------     ----                        ----------
Cmdlet          Find-Package                PackageManagement
Cmdlet          Get-Package                 PackageManagement
Cmdlet          Get-PackageProvider         PackageManagement
Cmdlet          Get-PackageSource           PackageManagement
Cmdlet          Install-Package             PackageManagement
Cmdlet          Register-PackageSource      PackageManagement
Cmdlet          Save-Package                PackageManagement
Cmdlet          Set-PackageSource           PackageManagement
Cmdlet          Uninstall-Package           PackageManagement
Cmdlet          Unregister-PackageSource    PackageManagement

Chocolateyのインストール

Chocolateyをインストールしていない方は、
Chocolateyをインストールして下さい。

chocolateyInstall
iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))

ChocolateyをPackageProviderとPackageSourceに登録

さて、ChocolateyはPackageSourceに登録されているでしょうか?

Get-PackageSource
PS > Get-PackageSource
Name       ProviderName  IsTrusted  IsRegistered IsValidated Location
----       ------------  ---------  ------------ ----------- --------
PSGallery  PSModule      False      True         False        https://www.powershellgallery...

Chocolateyが入っていないので足す必要があります。

ChocolateySourceを追加
PS > Get-PackageProvider Chocolatey -ForceBootstrap

Name       Version      DynamicOptions
----       -------      --------------
Chocolatey 2.8.5.130    {SkipDependencies, ContinueOnFailure, ExcludeVersion, ForceX86...}

やっとこれで使えますね。
何かインストールしてみましょう。

PackageManagementでインストール

何かインストールしてみましょう。
Flash Playerが古いのでFlash Playerを入れます。

FlashPlayerを探す
PS > Find-Package -Name flash
Name                 Version          Source           Summary
----                 -------         ------           -------
flashplayerplugin    18.0.0.194       chocolatey       Adobe Flash Player Plugin for other browsers
flashplayeractivex   18.0.0.160       chocolatey       Adobe Flash Player ActiveX for Internet Explorer
flashdevelop         4.7.2            chocolatey       Open source code editor for Actionscript, Haxe and 

インストールは管理者権限で立ち上げたPowershellのターミナル上で実行します。

Flashをインストール
# インストールは管理者権限が必要
PS > Install-Package -Name flashplayerplugin

The package(s) come from a package source that is not marked as trusted.
Are you sure you want to install software from 'chocolatey'?
[Y] はい(Y)  [N] いいえ(N)  [S] 中断(S)  [?] ヘルプ (既定値は "Y"): Y

Name              Version    Source      Summary
----              -------    ------      -------
flashplayerplugin 18.0.0.194 chocolatey  Adobe Flash Player Plugin for other browsers

Flashが入っているか確認
PS > get-package -Name flash

Name                           Version     Source           Summary
----                           -------     ------           -------
flashplayeractivex             18.0.0.160  C:\Chocolatey... Adobe Flash Player ActiveX for Internet Explorer
flashplayerplugin              18.0.0.194  C:\Chocolatey... Adobe Flash Player Plugin for other browsers
Adobe Flash Player 18 ActiveX  18.0.0.194  C:\Users\yusu...
Adobe Flash Player 18 NPAPI    18.0.0.194  C:\Users\yusu...

参考文献

Windows 10 - Powershell - PackageManagement - Install-Package - 'not a properly-formed module'

Package Management Preview for PowerShell 4 & 3 is now available

45
51
9

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
45
51