<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ja">
	<id>https://ja.wiki.hidekisaito.com/wiki/index.php?action=history&amp;feed=atom&amp;title=PowerShell%E3%83%A2%E3%82%B8%E3%83%A5%E3%83%BC%E3%83%AB%E3%81%AE%E4%BD%9C%E6%88%90%E6%96%B9%E6%B3%95</id>
	<title>PowerShellモジュールの作成方法 - 版の履歴</title>
	<link rel="self" type="application/atom+xml" href="https://ja.wiki.hidekisaito.com/wiki/index.php?action=history&amp;feed=atom&amp;title=PowerShell%E3%83%A2%E3%82%B8%E3%83%A5%E3%83%BC%E3%83%AB%E3%81%AE%E4%BD%9C%E6%88%90%E6%96%B9%E6%B3%95"/>
	<link rel="alternate" type="text/html" href="https://ja.wiki.hidekisaito.com/wiki/index.php?title=PowerShell%E3%83%A2%E3%82%B8%E3%83%A5%E3%83%BC%E3%83%AB%E3%81%AE%E4%BD%9C%E6%88%90%E6%96%B9%E6%B3%95&amp;action=history"/>
	<updated>2026-10-18T11:52:20Z</updated>
	<subtitle>このウィキのこのページに関する変更履歴</subtitle>
	<generator>MediaWiki 1.31.1</generator>
	<entry>
		<id>https://ja.wiki.hidekisaito.com/wiki/index.php?title=PowerShell%E3%83%A2%E3%82%B8%E3%83%A5%E3%83%BC%E3%83%AB%E3%81%AE%E4%BD%9C%E6%88%90%E6%96%B9%E6%B3%95&amp;diff=1890&amp;oldid=prev</id>
		<title>2018年11月28日 (水) 10:21にHsaitoによる</title>
		<link rel="alternate" type="text/html" href="https://ja.wiki.hidekisaito.com/wiki/index.php?title=PowerShell%E3%83%A2%E3%82%B8%E3%83%A5%E3%83%BC%E3%83%AB%E3%81%AE%E4%BD%9C%E6%88%90%E6%96%B9%E6%B3%95&amp;diff=1890&amp;oldid=prev"/>
		<updated>2018-11-28T10:21:01Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;ja&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;← 古い版&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;2018年11月28日 (水) 10:21時点における版&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l6&quot; &gt;6行目:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;6行目:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;=== PSD1ファイルの作成 ===&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;=== PSD1ファイルの作成 ===&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;モジュールはサブディレクトリと同じ名前のPSD1ファイルを持つ必要がある。これがなくとも&amp;lt;code&amp;gt;Import-Module&amp;lt;/code&amp;gt; &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;Cmdletを使用して、読み込むことはできるけど不便。このファイルがあることにより、Cmdletが実行された際に自動読み込みを行うことができる。尚、&lt;/del&gt;[https://www.powershellgallery.com/ PowerShell Gallery]などに公開する場合は、PSD1ファイルはメタデータ提供手段として必須。&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;モジュールはサブディレクトリと同じ名前のPSD1ファイルを持つ必要がある。これがなくとも&amp;lt;code&amp;gt;Import-Module&amp;lt;/code&amp;gt; &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;Cmdletを使用して、読み込むことはできるけど不便。このファイルがあることにより、Cmdletが実行された際に動的に自動読み込みを行うことができる。尚、&lt;/ins&gt;[https://www.powershellgallery.com/ PowerShell Gallery]などに公開する場合は、PSD1ファイルはメタデータ提供手段として必須。&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;以下は[https://github.com/hsaito/MyNumberPS MyNumberPS]における例。このファイル自体は&amp;lt;code&amp;gt;New-ModuleManifest&amp;lt;/code&amp;gt; Cmdletを使用して動的に生成することができる。&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;以下は[https://github.com/hsaito/MyNumberPS MyNumberPS]における例。このファイル自体は&amp;lt;code&amp;gt;New-ModuleManifest&amp;lt;/code&amp;gt; Cmdletを使用して動的に生成することができる。&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l45&quot; &gt;45行目:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;45行目:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Binary&amp;#160; &amp;#160;  1.2.0.0&amp;#160; &amp;#160; MyNumberPS&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; Core&amp;#160; &amp;#160; &amp;#160; {Get-MyNumber, Test-MyNumber, Get-MyNumberRange}&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Binary&amp;#160; &amp;#160;  1.2.0.0&amp;#160; &amp;#160; MyNumberPS&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; Core&amp;#160; &amp;#160; &amp;#160; {Get-MyNumber, Test-MyNumber, Get-MyNumberRange}&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;バイナリモジュールの代わりにスクリプトモジュールを使用する場合は、&amp;lt;code&amp;gt;.ps1&amp;lt;/code&amp;gt;を指定する。&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;=== ヘルプファイル ===&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;=== ヘルプファイル ===&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Hsaito</name></author>
		
	</entry>
	<entry>
		<id>https://ja.wiki.hidekisaito.com/wiki/index.php?title=PowerShell%E3%83%A2%E3%82%B8%E3%83%A5%E3%83%BC%E3%83%AB%E3%81%AE%E4%BD%9C%E6%88%90%E6%96%B9%E6%B3%95&amp;diff=1888&amp;oldid=prev</id>
		<title>Hsaito: ページの作成:「== .NETバイナリモジュール == .NETのバイナリモジュールを作成する場合は、クラスライブラリを作成し、それを&lt;code&gt;Cmdlet&lt;/code&gt;よ...」</title>
		<link rel="alternate" type="text/html" href="https://ja.wiki.hidekisaito.com/wiki/index.php?title=PowerShell%E3%83%A2%E3%82%B8%E3%83%A5%E3%83%BC%E3%83%AB%E3%81%AE%E4%BD%9C%E6%88%90%E6%96%B9%E6%B3%95&amp;diff=1888&amp;oldid=prev"/>
		<updated>2018-11-22T03:01:49Z</updated>

		<summary type="html">&lt;p&gt;ページの作成:「== .NETバイナリモジュール == .NETのバイナリモジュールを作成する場合は、クラスライブラリを作成し、それを&amp;lt;code&amp;gt;Cmdlet&amp;lt;/code&amp;gt;よ...」&lt;/p&gt;
&lt;p&gt;&lt;b&gt;新規ページ&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== .NETバイナリモジュール ==&lt;br /&gt;
.NETのバイナリモジュールを作成する場合は、クラスライブラリを作成し、それを&amp;lt;code&amp;gt;Cmdlet&amp;lt;/code&amp;gt;より継承する。尚、PowerShellのRunspaceを使用する必要がある場合は、&amp;lt;code&amp;gt;PSCmdlet&amp;lt;/code&amp;gt;から継承する。&amp;lt;code&amp;gt;PSCmdlet&amp;lt;/code&amp;gt;を使用するとPowerShellのランタイムに依存するため、これが好ましくない場合は&amp;lt;code&amp;gt;Cmdlet&amp;lt;/code&amp;gt;を使用する。ただし、この場合、Runspaceに依存するいくつかの機能が使用できなくなる。&lt;br /&gt;
&lt;br /&gt;
== モジュールを構成する場合の注意 ==&lt;br /&gt;
モジュールを構成後、モジュールをモジュールパス(&amp;lt;code&amp;gt;$Env:PSModulePath&amp;lt;/code&amp;gt;)のサブディレクトリに配置することにより、読み込めるようになるが、この場合いくつか注意する必要がある。&lt;br /&gt;
&lt;br /&gt;
=== PSD1ファイルの作成 ===&lt;br /&gt;
モジュールはサブディレクトリと同じ名前のPSD1ファイルを持つ必要がある。これがなくとも&amp;lt;code&amp;gt;Import-Module&amp;lt;/code&amp;gt; Cmdletを使用して、読み込むことはできるけど不便。このファイルがあることにより、Cmdletが実行された際に自動読み込みを行うことができる。尚、[https://www.powershellgallery.com/ PowerShell Gallery]などに公開する場合は、PSD1ファイルはメタデータ提供手段として必須。&lt;br /&gt;
&lt;br /&gt;
以下は[https://github.com/hsaito/MyNumberPS MyNumberPS]における例。このファイル自体は&amp;lt;code&amp;gt;New-ModuleManifest&amp;lt;/code&amp;gt; Cmdletを使用して動的に生成することができる。&lt;br /&gt;
&amp;lt;code&amp;gt;FunctionsToExport&amp;lt;/code&amp;gt;に指定している関数はCmdletとして使用できるようになる。こちらはワイルドカード&amp;#039;*&amp;#039;も使用できるらしいが、うまく動作しない。&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
@{&lt;br /&gt;
    RootModule = &amp;#039;MyNumberPS.dll&amp;#039;&lt;br /&gt;
    ModuleVersion = &amp;#039;1.2.0.0&amp;#039;&lt;br /&gt;
    FunctionsToExport = @(&lt;br /&gt;
            &amp;#039;Get-MyNumber&amp;#039;&lt;br /&gt;
            &amp;#039;Test-MyNumber&amp;#039;&lt;br /&gt;
            &amp;#039;Get-MyNumberRange&amp;#039;&lt;br /&gt;
        )&lt;br /&gt;
    CmdletsToExport   = &amp;#039;*&amp;#039;&lt;br /&gt;
    VariablesToExport = &amp;#039;*&amp;#039;&lt;br /&gt;
    AliasesToExport   = &amp;#039;*&amp;#039;&lt;br /&gt;
    GUID = &amp;#039;de6fc708-4172-4685-abf4-2cd5930e6ba9&amp;#039;&lt;br /&gt;
    Author = &amp;#039;Hideki Saito&amp;#039;&lt;br /&gt;
    Description = &amp;#039;MyNumber Module for PowerShell&amp;#039;&lt;br /&gt;
    PowerShellVersion = &amp;#039;6.0&amp;#039;&lt;br /&gt;
    CompatiblePSEditions = &amp;#039;Core&amp;#039;&lt;br /&gt;
    Copyright = &amp;#039;(c) 2018 Hideki Saito. All rights reserved.&amp;#039;&lt;br /&gt;
    PrivateData = @{&lt;br /&gt;
        PSData = @{&lt;br /&gt;
            ProjectUri = &amp;#039;https://github.com/hsaito/MyNumberPS/&amp;#039;&lt;br /&gt;
            LicenseUri = &amp;#039;https://github.com/hsaito/MyNumberPS/blob/master/LICENSE&amp;#039;&lt;br /&gt;
            ReleaseNotes = &amp;#039;&amp;#039;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
この後、&amp;lt;code&amp;gt;Get-Module -ListAvailable&amp;lt;/code&amp;gt;でモジュールが表示されていればモジュールのインストールは成功している。&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Binary     1.2.0.0    MyNumberPS                          Core      {Get-MyNumber, Test-MyNumber, Get-MyNumberRange}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== ヘルプファイル ===&lt;br /&gt;
PowerShellのヘルプファイルは書くのが面倒くさいので、[https://github.com/PowerShell/platyPS platyPS]を使用してマークダウン書式で書くのが一番楽。&lt;br /&gt;
platyPSはDeskエディション(つまりCoreではなく、Windows PowerShell)のモジュールなので、WindowsCompatibibilityモジュールのインストールが必要になる。&lt;br /&gt;
&lt;br /&gt;
モジュールを読み込んだあとに、&amp;lt;code&amp;gt;New-MarkdownHelp&amp;lt;/code&amp;gt; Cmdletを使用すると、モジュールに基づいたファイルが生成されるので、それを編集する。編集後、&amp;lt;code&amp;gt;New-ExternalHelp&amp;lt;/code&amp;gt; Cmdletを使用すると、XMLファイルが生成されるので、それをモジュールが入っているディレクトリにコピーする。これで、モジュールの読み込み時にヘルプも読み込まれるようになる。&lt;br /&gt;
&lt;br /&gt;
尚、モジュールに変更が加わった場合は&amp;lt;code&amp;gt;Update-MarkdownHelpModule&amp;lt;/code&amp;gt; Cmdletを使用すると、マークダウンファイルが更新される。&lt;br /&gt;
&lt;br /&gt;
[[Category:技術]]&lt;br /&gt;
[[Category:.NET]]&lt;br /&gt;
[[Category:PowerShell]]&lt;br /&gt;
[[Category:PowerShell Core]]&lt;/div&gt;</summary>
		<author><name>Hsaito</name></author>
		
	</entry>
</feed>