{"id":73781,"date":"2015-08-24T00:01:00","date_gmt":"2015-08-24T00:01:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2015\/08\/24\/verify-powershell-module-manifests\/"},"modified":"2019-02-18T09:35:30","modified_gmt":"2019-02-18T16:35:30","slug":"verify-powershell-module-manifests","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/verify-powershell-module-manifests\/","title":{"rendered":"Verify PowerShell Module Manifests"},"content":{"rendered":"<p><b>Summary<\/b>: Ed Wilson, Microsoft Scripting Guy, talks about verifying Windows PowerShell module manifests.<\/p>\n<p>Microsoft Scripting Guy, Ed Wilson, is here. One of the things that is cool about Windows PowerShell is that it is self-describing. I can type <b>Get-Member<\/b> or <b>Get-Command<\/b> and find out what a Windows PowerShell cmdlet is all about. Then there is <b>Get-Help<\/b>, which also provides way cool information. When cmdlets ship in Windows PowerShell modules, there are additional tools available. I can use <b>Get-Module<\/b> to see what a module contains.<\/p>\n<p>But there is more&hellip;<\/p>\n<p>I can look at the module manifest. When I create a Windows PowerShell module, I always like to create a module manifest. This is more important than it was, say, back in the Windows PowerShell 2.0 days. In fact, if I want to share my module with others, it is essential that I provide a manifest.<\/p>\n<h2>About module manifests<\/h2>\n<p>Windows PowerShell module manifests are files that have a .psd1 file extension. They are simple text files. Here is an example of a module manifest from the <b>PowerShellGet<\/b> module:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/hsg-8-24-15-01.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/hsg-8-24-15-01.png\" alt=\"Image of command output\" title=\"Image of command output\" \/><\/a><\/p>\n<p>To find the path to a module, I can use the <b>Path<\/b> property from the <b>PSModuleInfo<\/b> object, which is returned by the <b>Get-Module<\/b> cmdlet, for example:<\/p>\n<p style=\"margin-left:30px\">PS C:\\Users\\mredw&gt; (Get-Module PSReadline).path<\/p>\n<p style=\"margin-left:30px\">C:\\Program Files\\WindowsPowerShell\\Modules\\PSReadline\\1.1\\PSReadLine.psm1<\/p>\n<p>Note that sometimes this points to the module, and other times, it points to the module manifest. Here is an example of one that points to a module manifest:<\/p>\n<p style=\"margin-left:30px\">PS C:\\Users\\mredw&gt; (Get-Module Microsoft.PowerShell.Utility).path<\/p>\n<p style=\"margin-left:30px\">C:\\windows\\system32\\windowspowershell\\v1.0\\Modules\\Microsoft.PowerShell.Utility\\Microsoft.PowerShell.Utility.psd1<\/p>\n<h2>Test the manifest<\/h2>\n<p>If my path command points to a .psd1 file, I can directly use the <b>Path<\/b> property to test the module manifest. This is shown here:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/hsg-8-24-15-02.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/hsg-8-24-15-02.png\" alt=\"Image of command output\" title=\"Image of command output\" \/><\/a><\/p>\n<p>There is a lot of information returned by the <b>Test-ModuleManifest<\/b> cmdlet. The important thing is that in Windows PowerShell&nbsp;5.0, it also verifies the paths to all associated files. In this way, the <b>Test-ModuleManifest <\/b>cmdlet is also a troubleshooting tool.<\/p>\n<p>I can use the <b>ModuleBase<\/b> property to find the location of a module, and therefore, to find the module manifest. This is shown here:<\/p>\n<p style=\"margin-left:30px\">PS C:\\&gt; gci (Get-Module PSReadline).modulebase -Filter *.psd1<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp; Directory: C:\\Program Files\\WindowsPowerShell\\Modules\\PSReadline\\1.1<\/p>\n<p style=\"margin-left:30px\">Mode&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;LastWriteTime&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Length &nbsp;&nbsp;&nbsp;Name<\/p>\n<p style=\"margin-left:30px\">&#8212;- &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#8212;&#8212;&#8212;&#8212;-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8212;&#8212; &nbsp; &nbsp; &nbsp; &nbsp;&#8212;-<\/p>\n<p style=\"margin-left:30px\">-a&#8212;-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 7\/10\/2015&nbsp;&nbsp; 7:02 AM&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 787 PSReadline.psd1<\/p>\n<p>I can then pipe the output to the <b>Test-ModuleManifest<\/b> cmdlet and examine the manifest:<\/p>\n<p style=\"margin-left:30px\">PS C:\\&gt; gci (Get-Module PSReadline).modulebase -Filter *.psd1 | % {Test-ModuleManifest -Path $_.fullname}<\/p>\n<p style=\"margin-left:30px\">ModuleType &nbsp;&nbsp;&nbsp;Version&nbsp;&nbsp;&nbsp; Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;ExportedCommands<\/p>\n<p style=\"margin-left:30px\">&#8212;&#8212;&#8212;- &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#8212;&#8212;-&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8212;-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8212;&#8212;&#8212;-<\/p>\n<p style=\"margin-left:30px\">Script&nbsp;&nbsp;&nbsp;&nbsp; 1.1&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PSReadline&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;{Get-PSReadlineKeyHandl&#8230;<\/p>\n<p>That is all there is to examining module manifests. Join me tomorrow when I will talk about more cool stuff.<\/p>\n<p>I invite you to follow me on <a href=\"http:\/\/bit.ly\/scriptingguystwitter\" target=\"_blank\">Twitter<\/a> and <a href=\"http:\/\/bit.ly\/scriptingguysfacebook\" target=\"_blank\">Facebook<\/a>. If you have any questions, send email to me at <a href=\"mailto:scripter@microsoft.com\" target=\"_blank\">scripter@microsoft.com<\/a>, or post your questions on the <a href=\"http:\/\/bit.ly\/scriptingforum\" target=\"_blank\">Official Scripting Guys Forum<\/a>. See you tomorrow. Until then, peace.<\/p>\n<p><b>Ed Wilson, Microsoft Scripting Guy<\/b><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Summary: Ed Wilson, Microsoft Scripting Guy, talks about verifying Windows PowerShell module manifests. Microsoft Scripting Guy, Ed Wilson, is here. One of the things that is cool about Windows PowerShell is that it is self-describing. I can type Get-Member or Get-Command and find out what a Windows PowerShell cmdlet is all about. Then there is [&hellip;]<\/p>\n","protected":false},"author":596,"featured_media":87096,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[609,3,608,45],"class_list":["post-73781","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-powershell-5","tag-scripting-guy","tag-windows-10","tag-windows-powershell"],"acf":[],"blog_post_summary":"<p>Summary: Ed Wilson, Microsoft Scripting Guy, talks about verifying Windows PowerShell module manifests. Microsoft Scripting Guy, Ed Wilson, is here. One of the things that is cool about Windows PowerShell is that it is self-describing. I can type Get-Member or Get-Command and find out what a Windows PowerShell cmdlet is all about. Then there is [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/73781","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/users\/596"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/comments?post=73781"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/73781\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media\/87096"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media?parent=73781"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=73781"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=73781"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}