Created
November 11, 2020 06:55
-
-
Save Nillth/98fab98bed708e12b17b1a7dc4760a12 to your computer and use it in GitHub Desktop.
Merges all the Files in a PowerShell Script Module into a single file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$Modules = "Qlik-CLI" | |
foreach ($modulename in $Modules) { | |
$PSModule = Get-module -Name $modulename -ListAvailable | Sort-Object -property version | select -First 1 | |
$PSModuleData = Import-LocalizedData -BaseDirectory $PSModule.ModuleBase -FileName ([system.io.fileinfo]$PSModule.Path).name | |
$ResourceFiles = $PSModuleData.NestedModules + $PSModuleData.RootModule + $PSModuleData.ModuleToProcess | select -Unique | |
$ConsolidatedModules = foreach ($Module in $ResourceFiles) { | |
[system.io.fileinfo]$FilePath = Join-Path -Path $PSModule.ModuleBase -ChildPath $Module -Resolve | |
$FileContent = Get-Content $FilePath.FullName -Raw | |
@" | |
#region Source: $($Module) | |
$FileContent | |
#endregion Source: $($Module) | |
"@ | |
} | |
$OutFile = "$($PSModule.Name)_$($PSModule.Version).ps1" | |
$ConsolidatedModules | out-file -Encoding utf8 -FilePath $OutFile | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment