Invalid configuration: endpoints.ps1 - No Execution Environment Found

I keep getting an error when trying to create an API endpoint: Invalid configuration: endpoints.ps1 - No Execution Environment Found.

I was just trying this out of the examples, my endpoints.ps1 file:

New-PSUEndpoint -Url "/random" -Endpoint {
Get-Random -Min 100 -Max 1000
}

Searching the foums isn’t coming up with much on this one. I’ve otherwise been playing with PSU a lot the past few days and have been attempting to get my environment configured properly and would like to finally move on to building some Dashboards/Pages.

Product: PowerShell Universal
Version: 2.5.4

This could be a problem with environment.ps1 and settings.ps1. Do you have -DefaultEvironment or ApiEnvironment defined on Set-PSUSetting?

If so, does it match what is in environments.ps1?

I appear to be in business now. I did not have either of those defined. I tried manually adding those parameters with my “pwsh” environment and the service would crash every time. I ended up removing the parameters and went in and set them from the GUI, restarted the service, and no error. Even though the parameters now look like the same thing that I added manually.

Anyway, I was able to Invoke-RestMethod and get my data!

Thanks for leading me in the right direction! I’m ready for one of them weekends.

1 Like

Still having one weird issue though… Just trying to pull a number into a Statistic box on a Page.

The API is working now, but I’m still not getting a result from my scripts. Even if it’s the same code between the API and Script.