A few months ago we started to publish our PowerShell modules to PowerShellGallery. PowerShellGallery visualizes the PSData
defined in PrivateData
of module manifest, which got introduced in PowerShell 5.
# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell. PrivateData = @{ PSData = @{ # Tags applied to this module. These help with module discovery in online galleries. # Tags = @() # A URL to the license for this module. # LicenseUri = '' # A URL to the main website for this project. # ProjectUri = '' # A URL to an icon representing this module. # IconUri = '' # ReleaseNotes of this module # ReleaseNotes = '' } # End of PSData hashtable } # End of PrivateData hashtable
PrivateData part of a module manifest file created with the New-ModuleManifest
Cmdlet of PowerShell 5.
Because of that we extended the module manifest files of our existing modules with the PrivateData
hashtable as follows.
# Private data to pass to the module specified in RootModule/ModuleToProcess. PrivateData = @{ PSData = @{ # Tags applied to this module. These help with module discovery in online galleries. Tags = @('dfch', 'PowerShell', 'Appclusive', 'Automation', 'OData') # A URL to the license for this module. LicenseUri = 'https://github.com/dfensgmbh/biz.dfch.PS.Appclusive.Client/blob/master/LICENSE' # A URL to the main website for this project. ProjectUri = 'https://github.com/dfensgmbh/biz.dfch.PS.Appclusive.Client' # A URL to an icon representing this module. IconUri = 'https://raw.githubusercontent.com/dfensgmbh/biz.dfch.PS.Appclusive.Client/master/logo-32x32.png' # ReleaseNotes of this module ReleaseNotes = 'Initial Release` }
PSData
hashtable got introduced with PowerShell 5. As most of our PowerShell modules have to be compatible with PowerShell 3 we verified, if the module manifest files created with PowerShell 5 are still compatible with PowerShell 3. They are. The only problem is, that the Tags, as defined in the example above, are causing problems in PowerShell 3 during the import of the module.
During the execution of the Import-Module
Cmdlet the following error occurs.
iex : At line:257 char:18 + Tags = @("dfch", "PowerShell", "Appclusive", "Automation", "OData") + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Executable script code found in signature block. In C:\Program Files\WindowsPowerShell\Modules\biz.dfch.PS.Appclusive.Client\biz.dfch.PS.Appclusive.Client.psm1:35 Char:56 + $Manifest = (Get-Content -raw $ManifestPathAndFile) | iex; + ~~~ + CategoryInfo : ParserError: (:) [Invoke-Expression], ParseException + FullyQualifiedErrorId : TokenAfterEndOfValidScriptText,Microsoft.PowerShell.Commands.InvokeExpressionCommand Import-Module : The module to process "biz.dfch.PS.Appclusive.Client.psm1", listed in field "ModuleToProcess/RootModule" of module manifest "C:\Program Files\WindowsPowerShell\Modules\biz.dfch.PS.Appclusive.Client\biz.dfch.PS.Appclusive.Client.psd1" was not processed because no valid module was found in any module directory. At line:1 char:1 + Import-Module biz.dfch.PS.Appclusive.Client + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : ResourceUnavailable: (biz.dfch.PS.Appclusive.Client:String) [Import-Module], PSInvalidOperationException + FullyQualifiedErrorId : Modules_ModuleFileNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand
After an analysis of the problem I figured out, that the Tags
have to be defined differently to be compatible with PowerShell 3.
The formats supported by PowerShell 5:
Tags = @("dfch", "PowerShell", "Appclusive", "Automation", "OData") Tags = 'dfch', 'PowerShell', 'Appclusive', 'Automation', 'OData'
The format supported by PowerShell 3:
Tags = 'dfch', 'PowerShell', 'Appclusive', 'Automation', 'OData'
Changing the format of the Tags
to the format compatible with PowerShell 3 solved my problem.
P.S.
Testing the module manifest with the Test-ModuleManifest
Cmdlet of PowerShell 3 succeeds for both formats…
PS C:\windows\system32> Test-ModuleManifest -Path 'PATH\TO\MODULE_MANIFEST\example.psd1'