Failed to connect to PowerShell Universal

Hi,

I’ve downloaded and installed the MSI and the service is running and I can log in to the web portal.
I’ve then downloaded and added the VS code extension. My Admin account doesn’t have internet access.
I’ve generated an app token, kept it as localhost as VS code is on the same machine and port 5000.
But when I launch the extension, it says

“Failed to connect to PowerShell Universal. You can configure the connection information in settings.”

I can see the correct URL in the bottom left “connecting to PowerShell universal at http://localhost:5000…”

Are there any debug logs I could use to find out why its not connecting?

Thanks

Can you try running this in a PS Prompt?

Invoke-WebRequest http://localhost:5000/api/v1/accessible -Headers @{ Authorization = "Bearer <apptoken>" }

Hi Adam,

Yes sure I get:

tatusCode : 200
StatusDescription : OK
Content : {“username”:“Admin”,“roles”:[“Administrator”,“Operator”,“Reader”]}
RawContent : HTTP/1.1 200 OK
Transfer-Encoding: chunked
Content-Type: application/json; charset=utf-8
Date: Thu, 15 Oct 2020 15:28:18 GMT
Server: Kestrel

                {"username":"Admin","roles":["Administrator","Operat...

Forms : {}
Headers : {[Transfer-Encoding, chunked], [Content-Type, application/json; charset=utf-8], [Date, Thu, 15 Oct 2020 15:28:18 GMT], [Server, Kestrel]}
Images : {}
InputFields : {}
Links : {}
ParsedHtml : mshtml.HTMLDocumentClass
RawContentLength : 66

The same problem occurs with my instance

StatusCode        : 200
StatusDescription : OK
Content           : {"username":"Server","roles":["Administrator"]}
RawContent        : HTTP/1.1 200 OK
                    Date: Thu, 15 Apr 2021 12:12:35 GMT
                    Server: Kestrel
                    Transfer-Encoding: chunked
                    Content-Type: application/json; charset=utf-8

                    {"username":"Server","roles":["Administrator"]}
Headers           : {[Date, System.String[]], [Server, System.String[]], [Transfer-Encoding, System.String[]],
                    [Content-Type, System.String[]]}
Images            : {}
InputFields       : {}
Links             : {}
RawContentLength  : 47
RelationLink      : {}

I am running the server executable directly instead of start-psuserver.

Upon clicking the VSCode plugin i get this error
image

Is there another way to have the plugin connect again without having to relaunch VSCode?

You will want to update your settings for the extension.

It looks like it’s trying to start the PSU server itself. Open the settings by pressing Ctrl+Shift+P and searching for the settings UI. There will be a section for PowerShell Universal.

You can set the extension to not start PSU and you can reset the app token as well.

That resolves that specific error, but now i get this error
image

This my current configuration

Are you running PSU on port 80? You might want to try to set the port in the URL.

It is running 443, with the port configured i get the same error.

When i run the dashboard on port 80, without the port configured in the settings, the extension can connect. Disadvantage is that Azure oidc authentication responds with an error 500. The port 80 redirect url is configured within my app registration. Is it possible it is having difficulty with the certificate? Powershell universal is running locally and i used dotnet to generate certificates.

dotnet dev-certs https
dotnet dev-certs https --trust

For my problem i got the following workaround. By having the dashboard running at port 80 and 443 the extension is allowed to connect and i can access the website through 443.

"Kestrel": {
"Endpoints": {
  "HTTPS": {
    "Url": "https://*"
  },
  "HTTP": {
    "Url": "http://*"
  }
},
"RedirectToHttps": "false"

},