Update-ModuleManifest flattening FunctionsToExport into a String
Using New-ModuleManifest with FunctionsToExport as an array creates the proper field:
FunctionsToExport = 'function1', 'function2', 'function3'
But if I run Update-ModuleManifest on the manifest file, the FunctionsToExport will get flattened to a single string:
FunctionsToExport = 'function1 function2 function3'

Sorry for the lag in returning to this thread.
From the feedback, it looks like this has been corrected in 5.1, and we are unable to reproduce it internally. If someone can reproduce this with either the 5.1 preview, the client Anniversary Edition, or Server 2016 TP5 (& later) PLEASE reactivate this issue. Thank you!
7 comments
-
Dirk Manly commented
I have the same issue,
Name Value
---- -----
PSVersion 5.0.10586.117
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.10586.117
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1Directory: C:\Program Files\WindowsPowerShell\Modules
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Script 1.0.0.1 PowerShellGet {Install-Module, Find-Module, Save-Module, Update-Module...}Updating the ExportedFunctions, Aliases,Variables and CmdLets in PSModule.ps1 got me working again. Thanks to Mr. Pugh
-
Henry Buckle commented
Looks like this is fixed in the 5.1 preview
-
Henry Buckle commented
I see the same thing on Server 2012R2 - it does the same thing to the Required Assemblies field
PS C:\Windows\system32> $psversiontable
Name Value
---- -----
PSVersion 5.0.10586.117
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.10586.117
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1PS C:\Windows\system32> get-module PowerShellGet -li
Directory: C:\Program Files\WindowsPowerShell\Modules
ModuleType Version Name
---------- ------- ----
Script 1.0.0.1 PowerShellGet -
Martin Pugh commented
And:
Get-Module powershellget -liDirectory: C:\Program Files\WindowsPowerShell\Modules
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Script 1.0.0.1 PowerShellGet {Install-Module, Find-Module, Save-Module, Update-Module...} -
Martin Pugh commented
Sorry for the delay. I'm on a Windows 7 box with PS 5 installed:
Name Value
---- -----
PSVersion 5.0.10586.117
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.10586.117
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1BEFORE:
# Functions to export from this module
FunctionsToExport = 'Show-HDSize', 'Compare-ADGroupMember', 'Get-AdapterInfo',
'Get-ComputerInfo', 'Get-DiskInfo', 'Get-OUFullyQualifiedDomainName',
'Get-ServiceInfo', 'Get-Uptime', 'Get-VMScreenShot', 'Get-WhatIsMyIP',
'Get-WQLQuery', 'New-RandomPassword', 'Restart-ComputerAndWait',
'Test-ADAuthentication', 'Write-Log'
COMMAND: Update-ModuleManifest -Path .\Surly.PowerShell.Tools.psd1 -ModuleVersion 3.0.0AFTER:
# Functions to export from this module
FunctionsToExport =
'Show-HDSize Compare-ADGroupMember Get-AdapterInfo Get-ComputerInfo Get-DiskInfo Get-OUFullyQualifiedDomainName Get-ServiceInfo Get-Uptime Get-VMScreenShot Get-WhatIsMyIP Get-WQLQuery New-RandomPassword Restart-ComputerAndWait Test-ADAuthentication Write-Log' -
Chris Hunt commented
I am on 5.1.14361.0 and it appears to maintain the array now.
-
Martin Pugh commented
Looks like a simple fix. Line 448 (I'm pasting the whole section which actually starts at 438). When using $moduleInfo.ExportedFunctions.Keys this does not generate a [string[]] type, but a KeyCollection. This must be getting flattened by New-ModuleManifest when creating the temp manifest file.
Simply casting the variable as [string[]] should solve the issue:
if($FunctionsToExport)
{
$params.Add("FunctionsToExport",$FunctionsToExport)
}
else
{
#Since $moduleInfo.ExportedFunctions is a hashtable, we need to take the name of the
#functions and make them into a list
if($moduleInfo.ExportedFunctions)
{
$params.Add("FunctionsToExport",[string[]]$moduleInfo.ExportedFunctions.Keys)
}
}