Functions/Update-MyModuleManifest.ps1
function Update-MyModuleManifest { [CmdletBinding()] param ( [Parameter()] [ArgumentCompleter( { param ( $commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameters ) Get-ChildItem "$([Environment]::GetFolderPath("MyDocuments"))\WindowsPowerShell\Modules\$wordToComplete*" -Directory -Name | ForEach-Object { "`"$_`"" } } )] [string] $Module ) #Set-Location $MyModulePath $MyModulePath = "$([Environment]::GetFolderPath("MyDocuments"))\WindowsPowerShell\Modules" if ($Module) { $ModuleFolders = Get-ChildItem $MyModulePath -Directory -Exclude ".git" | Where-Object Name -EQ $Module } else { $ModuleFolders = Get-ChildItem $MyModulePath -Directory -Exclude ".git", "PackageManagement" } foreach ($m in $ModuleFolders) { Write-Output "Updating module: $($m.BaseName)" $FunctionsToExport = (Get-ChildItem (Join-Path $m.FullName -ChildPath "Functions") -File).BaseName $VariablesToExport = @('absolutelynothing') if (Test-Path (Join-Path $m.FullName -ChildPath "Variables")) { $VariablesToExport = (Get-ChildItem (Join-Path $m.FullName -ChildPath "Variables")).BaseName } if (Test-Path (Join-Path $m.FullName -ChildPath "Other\RequiredModules.csv")) { $RequiredModules = Import-Csv (Join-Path $m.FullName -ChildPath "Other\RequiredModules.csv") | Select-Object -ExpandProperty Modulename } else { $RequiredModules = @() } if (Test-Path (Join-Path $m.FullName -ChildPath "Other\ModuleDescription.txt")) { $ModuleDescription = Get-Content (Join-Path $m.FullName -ChildPath "Other\ModuleDescription.txt") } else { $ModuleDescription = $m.BaseName } $ModuleInfo = Get-Module $m.BaseName -ListAvailable $CurrentVersion = $ModuleInfo.Version.Major $NewVersion = $CurrentVersion + 1 $NewVersion = "$($NewVersion).0" $ModuleManifestParameters = @{ Path = (Join-Path $m.FullName -ChildPath ($m.BaseName + ".psd1")) RootModule = $m.BaseName + ".psm1" ModuleVersion = $NewVersion FunctionsToExport = $FunctionsToExport VariablesToExport = $VariablesToExport } if ($RequiredModules) { $ModuleManifestParameters.Add("RequiredModules", $RequiredModules) } if ($ModuleDescription) { $ModuleManifestParameters.Add("Description", $ModuleDescription) } #$ModuleManifestParameters if (Test-Path $ModuleManifestParameters.Path) { Update-ModuleManifest @ModuleManifestParameters } else { New-ModuleManifest @ModuleManifestParameters } } #return $ModuleFolders } |