Hi There
Using UD 2.5.0 on OSX with Powershell Core
I’m trying to figure out what would be the best way to use modules in UD / EndPoints
For example, to use functions from a module I have written I import the module in the endpoint
New-UDGrid -Title “Servers” -Headers @(“Name”, “InstanceID”) -Properties @(“Name”, “InstanceID”) -Endpoint {
Import-Module -Name “…/Util/Modules/AWS.psm1” -DisableNameChecking -Force
Import-Module AWSPowerShell.NetCore
Set-DefaultAWSRegion -Region eu-west-1
$EC2Servers = Get-EC2Instance
$GridData = @()
foreach ($EC2Server in $EC2Servers) {
$EC2Name = Get-AWSTagValue -Tags $EC2Server.Instances[0].Tags -Key “Name”
$GridData += [PSCustomObject]@{
Name = $EC2Name
InstanceID = $EC2Server.Instances[0].InstanceId
}
}
$GridData | Out-UDGridData
}
As you might have guessed, this creates a grid full of server details. I f I do not import the modules then either the AWS cmdlets are not found or thge functions I wrote cannot be found.
But is there not a better way to include the modules globally in the dashboard then having to import them in each endpoint? I tried to use New-UDEndpointInitialization like so:
$EPModules = New-UDEndpointInitialization -Module @(“AWSPowerShell.NetCore”, “…/Util/Modules/AWS.psm1”)
And then load the dashoboard with the EndpointInitialization option like so:
New-UDDashboard -Title “Center” -Pages $Pages -EndpointInitialization $EndPoint_Modules
There are no error messages (I have logging turned on) but I get errors when I try to use functions/cmdlets from the modules.
So I was wondering, what is the best strategy to keep using modules and have them loaded only once in a dshboard session?