Skip to content

Dynamically Import Functions Into Scripts #4

@bic742

Description

@bic742

Currently, any new functions added to the module have to be manually imported into the required processors. If there are a number of imports already existing, then it can be tedious to update all of them. Instead, we should be dynamically importing all methods that are in the Module Functions and Custom Functions folders for the module:

$moduleId = "{9F3EEA96-CEC8-4C7D-B26B-6D15AB654AF1}"
$scriptTemplateId = "{DD22F1B3-BD87-4DB2-9E7D-F7A496888D43}"
$item = Get-Item -Path "master:" -ID $moduleId
$query = "$($item.ItemPath)/#Functions#//*[@@TemplateId='$($scriptTemplateId)']"
Get-Item -Path "master:" -Query $query | ForEach-Object { Import-Function -Name $_.Name }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions