Windows Management Framework 5.0 May Preview から、 PowerShellGet が追加されました。
Microsoft Download Center : Windows Management Framework 5.0 Preview May 2014
OneGet との違いを見てみましょう。
目次
用途
表にしてみると違いがわかりますか?
項目 | PowerShellGet | OneGet |
---|---|---|
用途 | PowerShell Module の取得 | ソフトウェア(Package)の取得 |
Module | PowerShellGet | OneGet |
コマンド | *-Module | *-Package |
取得対象 | PowerShell Resource Gallery | 現在はChocolateyのみ |
CodePlex, GitHub, various blogs, TechNet Script Centerなどからのモジュールを探す手間を、PowerShell Resource Galleryギャラリーからに登録することで省力化するのが目的ですね。 Nuget からだと思ったら違ってしょぼーん
OneGet Cmdlets
OneGet に含まれる Cmdlet 一覧です。
Get-Command -Module OneGet
CommandType Name Source ----------- ---- ------ Cmdlet Add-PackageSource OneGet Cmdlet Find-Package OneGet Cmdlet Get-Package OneGet Cmdlet Get-PackageSource OneGet Cmdlet Install-Package OneGet Cmdlet Remove-PackageSource OneGet Cmdlet Uninstall-Package OneGet
PowerShllGet Cmdlets
PowerShllGet に含まれる Cmdlet です。
Get-Command -Module PowerShellGet
CommandType Name Source ----------- ---- ------ Function Find-Module PowerShellGet Function Install-Module PowerShellGet Function Publish-Module PowerShellGet Function Update-Module PowerShellGet
Find-Module
まずは、Module の検索から。
PowerShellGet で、 モジュールを世界から探す場合は Find-Module
を利用します。OneGet の Find-Packege
と同様の命名規則ですね。
初回実行時には、次のように NuGet.exe が Galleries から取得するための許可を求めてきます。
NuGet.exe is required to continue. PowerShellGet requires NuGet.exe to interact with NuGet based galleries. NuGet.exe must be available in 'C:\Users\acquire\AppData\Local\Microsoft\Windows\PowerShell\PowerShellGet'. For more information about NuGet, see https://www.nuget.org. Do you want PowerShellGet to download NuGet.exe to 'C:\Users\acquire\AppData\Local\Microsoft\Windows\PowerShell\PowerShellGet' now? [Y] Yes [N] No [S] Suspend [?] Help (default is "Y"):
許可すると、モジュール一覧が表示されます。
Version Name DateUpdated Description ------- ---- ----------- ----------- 1.1.0.0 AutoVars 2014/05/13 6:37:19 Allows for the definition of automatic (calculated) variab... 1.0.0.0 CimInventory 2014/05/15 7:47:22 Module that should help read data from CIM/WMI data from r... 6.0 ConversionModule 2014/05/07 6:34:14 a module that performs various unit conversions 1.0 EWS 2014/05/12 3:20:17 Module to enable automating mail-related tasks 2.1.0.2 FAQ 2014/05/15 8:26:13 A Frequently Asked Questions (and answers) module as a dem... 1.0 GenericMethods 2014/05/09 2:53:45 The Invoke-GenericMethod function allows you to call gener... 1.2.0.0 HardwareManagement 2014/05/14 5:28:11 Out-of-band hardware management module 1.1 IEFavorites 2014/05/14 11:30:05 Used to manage Internet Explorer favorites 1.0 InlineMailAttachments 2014/05/09 2:33:11 This module contains a PowerShell re-implementation of the... 0.1.0.0 ISEGit 2014/05/12 3:48:48 Module to work with git in PowerShell ISE. Configured usin... 3.0 LocalUserManagement 2014/05/13 6:17:19 a module that performs various local user management funct... 1.0.0.5 LockObject 2014/05/14 9:41:05 Lock-Object is a PowerShell implementation of C#'s "lock" ... 1.0.0.0 MyDefaults 2014/05/08 4:47:21 Sets and gets default values for function parameters. Comp... 1.4 myModule 2014/05/09 2:18:33 My PowerShell Module for the demo! 1.0 PoshInternals 2014/05/07 21:56:43 Collection of system internals tools for PowerShell. 2.2.1 PoshWSUS 2014/05/07 11:48:49 PowerShell module to manage a WSUS Server. 1.2 PowerShellCookbook 2014/05/15 8:32:23 Sample scripts from the Windows PowerShell Cookbook 1.1 PowerShellHumanizer 2014/05/08 9:36:47 PowerShell Humanizer wraps Humanizer: meets all your .NET ... 4.0 PowerShellISEModule 2014/05/07 8:51:00 a module that adds capability to the ISE 1.1 PowerShellLogging 2014/05/07 14:02:02 Captures PowerShell console output to a log file. 1.0 PreferenceVariables 2014/05/09 2:59:43 The Get-CallerPreference function allows functions in Scri... 3.1.0.0 Pscx 2014/05/04 14:55:43 PowerShell Community Extensions (PSCX) base module which i... 1.0.0.8 PSReadline 2014/05/13 0:12:18 Great command line editing in the PowerShell console host 1.0.4.0 ScriptCS 2014/05/07 13:00:33 Allows execution of ScriptCS from your PowerShell session. 1.0 ScriptTransforms 2014/05/14 0:46:55 Enables you to define function parameter transformation at... 1.0.4.36 ScsmPx 2014/04/18 10:08:32 The ScsmPx module facilitates automation with Microsoft Sy... 1.0.0.1 SNMP 2014/05/14 2:51:13 Module to manage systems using SNMP. 2.0 SQLite 2014/05/15 8:22:23 The SQLite PowerShell Provider allows PowerShell to intera... 1.0 StringTokens 2014/05/09 4:00:40 The Get-StringToken function extracts tokens from a delimi... 1.1 TCPServer 2014/05/14 11:30:19 Module used to create a TCP Server locally or remotely and... 1.0.0.1 TestConnectionAsync 2014/05/09 2:38:51 Test-ConnectionAsync allows you to ping hundreds of addres... 1.1.0.0 TxF 2014/05/07 12:51:02 Provides transactional file system operations. 1.0.2.2 TypeAccelerator 2014/04/15 8:24:13 The TypeAccelerator module provides a set of commands that... 1.0.1 xActiveDirectory 2014/05/15 8:12:23 The xActiveDirectory module is a part of the Windows Power... 1.1.4 xAzureVMResources 2014/05/15 8:12:23 Module with DSC Resources for Azure Resources 1.2.1 xComputerManagement 2014/05/15 8:12:23 The xComputerManagement module is a part of the Windows Po... 1.1.1 xDatabase 2014/05/15 8:12:23 The xDatabase module is a part of the Windows PowerShell D... 1.0.1 xDscDiagnostics 2014/05/15 8:12:23 The xDscDiagnostics module is a part of the Windows PowerS... 1.1.1 xDSCResourceDesigner 2014/05/15 8:12:23 The xDscResourceDesigner module is a part of the Windows P... 1.1.1 xFailOverCluster 2014/05/15 8:12:23 The xFailOverCluster module is a part of the Windows Power... 2.1.1 xHyper-V 2014/05/15 8:12:23 The xHyper-V module is a part of the Windows PowerShell De... 0.2.16.1 xJea 2014/05/15 8:12:23 Module with DSC Resources for Just Enough Admin (JEA). Je... 2.1.1 xNetworking 2014/05/15 8:12:23 The xNetworking module is a part of the Windows PowerShell... 1.0.0 xOneGet 2014/05/15 8:12:23 DSC Resource for OneGet 2.0.1 xPSDesiredStateConfiguration 2014/05/15 8:12:23 The xPSDesiredStateConfiguration module is a part of the W... 1.0.1 xRemoteDesktopSessionHost 2014/05/15 8:12:23 The xRemoteDesktopSessionHost module is a part of the Wind... 1.0.1 xSmbShare 2014/05/15 8:12:23 The xSmbShare module is a part of the Windows PowerShell D... 1.1.2 xSqlPs 2014/05/15 8:12:23 The xSqlPs module is a part of the Windows PowerShell Desi... 1.0.1 xSystemSecurity 2014/05/15 8:12:23 The xSystemSecurity module is a part of the Windows PowerS... 1.3.1 xWebAdministration 2014/05/15 8:12:23 The xWebAdministration module is a part of the Windows Pow...
PowerShell Resource Galley
これらのモジュールが公開されているリポジトリが、PowerShell Resource Gallery です。
現在は Limited Preview のため、デモ利用以外に モジュールの作成などはできませんが、モジュール取得は可能です。
Publish-Module
Module を PowerShell Gallery に公開するときに利用します。
この時利用するのは NuGet API キーですが、現在は Preview リリースなので、apiキーが無効となり利用できません。
Publish-Module -Path ".\valentia\valentia" -NuGetApiKey $nugetApiKey -Tag PowerShell -LicenseUri "https://opensource.org/licenses/MIT" -ProjectUri "https://github.com/guitarrapc/valentia"
NuGet.exe : Failed to process request. 'The specified API key is invalid or does not have permission to access the specified package.'. At C:\windows\system32\windowspowershell\v1.0\Modules\PowerShellGet\SourceTypes\PSGallery\PSGallery.psm1:549 char:19 + ... $output = & $script:NuGetClient push $NupkgPath -source $PSGallery ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (Failed to proce...ied package.'. :String) [], RemoteException + FullyQualifiedErrorId : NativeCommandError The remote server returned an error: (403) Forbidden.. Publish-PSGetExtModule : Failed to publish module 'Pushing valentia 0.3.7 to 'https://go.microsoft.com/fwlink/?LinkID=397527&clcid=0x409'...'. At C:\windows\system32\windowspowershell\v1.0\Modules\PowerShellGet\PSGet.psm1:671 char:17 + Publish-PSGetExtModule -PSModuleInfo $moduleInfo ` + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [Write-Error], WriteErrorException + FullyQualifiedErrorId : FailedToPublishTheModule,Publish-PSGetExtModule
Install-Module
Find-Module で見つかった モジュールのインストールです。
すっごいいいですね!最高です。
Find-Module -Name PSReadline | Install-Module -Scope CurrentUser
これで、現在のユーザー Module フォルダにモジュールが入ります。
デフォルトのスコープが AllUser なため管理者権限を求めてきますが、 Scope を CurrentUser にすれば必要ありません。
Update-Module
インストールしたモジュールの更新はこれ1つです。
Update-Module -Name PSReadLine
もしNameを外せば、対象すべてとなります。
PS > Update-Module -Verbose VERBOSE: Checking for updates for module 'PSReadline'. VERBOSE: Found module 'PSReadline' with version '1.0.0.8'. VERBOSE: No updates were found for module 'PSReadline'.
まとめ
Publish させてくだされ~。試すので申請しておきました。