Function and Variable Scope

I would like to load a custom set of functions to use across multiple pages in my UD dashboard session. Is it best to make them a module, or where would be the best location to import them on startup? Right now, I’m repeating a lot of code in each page, like db queries, etc.

I have a .psm1 file for the main UD session, and a child .psm1 that gets imported within the Start-UDappname function which is exposed from the main module. The child module only imports dependent modules, but do i really need to do that? When I’ve tried adding functions to that child .psm1 , even with Export-ModuleMember , the functions aren’t seen by New-UDGrid -Endpoint {} blocks of code. I’m looking for how to make them visible in that scope.

This is what I do. I make a couple modules that contain things like common controls that I use more than once, functions, and any other variables that I need to pass in. I pass those modules into the New-UDEndpointInitialization -Module parameter and then they are accessible through out my dashboard.

1 Like

That sounds like a good way to go - thank you!

So on the API document for New-EndpointInitialization, under example 4, can you elaborate on that to show how to call a function exposed from the module (Hyper-V), such as Get-VM? In particular, I’d like to call a function that outputs through a UDGrid within a page.