PowerShell Universal and Pester

With PowerShell Universal, is there a way of starting a Dashboard on a custom port number like you could in Universal Dashboard 2.9? e.g. as below

$Server = Start-UDDashboard -Dashboard $Dashboard -Port 10000

This questions is really about how to create a Pester test for a custom control using the PowerShell Universal framework. The Pester test in the ud-custom-control-template is clearly written for UD and not PowerShell Universal.

I would like to be able to automatically stand up a temporary Dashboard, run my tests and bin it off.

Thanks
Edd

Hey Edd,

I’ve released a new blog post and template for Universal


To stand up a temporary server, you can use Start-PSUServer in the Universal module and pass in a listen address with your custom port.

Start-PSUServer -ListenAddress http://localhost:12345

The Start-PSUServer function is just a wrapper around start process.

function Start-PSUServer {
    param(
        [Parameter()]
        $ExecutablePath = "Universal.Server.exe",
        [Parameter()]
        $ListenAddress
    )

    $Command = Get-Command $ExecutablePath -ErrorAction SilentlyContinue
    if ($null -eq $Command)
    {
        throw 'Unable to locate the Universal Server executable. You can use Install-PSUServer to download the latest version. Use the -UpdatePathVariable parameter to add the installation directory the the PATH.'
    }

    if ($ListenAddress)
    {
        $Env:Kestrel__Endpoints__HTTP__Url = $ListenAddress
    }

    Start-Process -FilePath $ExecutablePath 
}

You can actually set any setting you’d like via environment variables so you could adjust the path to where PSU looks for the configuration files: https://docs.ironmansoftware.com/config/settings

Where ever you set the repository dir to, you could create your dashboard.ps1 and dashboards.ps1 to use your custom component. I would consider just using the UI to generate all the config files and then include them in your repo so you can just point the temporary PSU instance at them.

Fantastic!

I will have a read and thanks for the pointer on how to integrate this with Pester tests.

All the best

If you figure out a good way for testing with Pester, I’d be happy to merge that into the template repository because I think that will help anyone creating a customer component.