Invoke-RestMethod : Unable to connect to the remote server

Hello. I’m not only new to the community, I’m pretty much new to scripting which includes powershell and not to mention PSUD and i’m also not a coder. But I have managed to piece together a few scripts that have suited my purposes for monitoring some software I need to know that is or isn’t running. So here’s the trouble:

I’m running a PSUD desktop API on a remote PC that is not in my local network. I don’t need to worry about port forwarding because this PC has a public IP. The API i’m running is just a simple test, "get-process firefox. That’s it.

When I run the API in the PS console on the remote pc using:

“Invoke-RestMethod http://localhost:5000/get -Method GET”

it works. But, when I attempt to invoke the API from my laptop using the following:

“Invoke-RestMethod http://xxx.xxx.xxx.xxx:5000/get -Method GET”

I get:

“Invoke-RestMethod : Unable to connect to the remote server”

I tried everything I could find in the forums and online including; using “Invoke-WebRequest”, running the script with a variable, using -Uri, using https, putting quotes around ‘GET’ and several other things I can’t remember atm.

It’s clear that i’m very inexperienced in this world but I’m willing to learn in order to get the results that I’m after. I have successfully created a few PSU dashboards so far that i’m proud of but I seem to be out of my depth on this one. Any help would be appreciated.

Things you should probably know… Although I have a licensed version of PSUD desktop on my laptop, The remote PC with the simple API i’m trying to call is unlicensed (but in this case I don’t believe it matters). I am also running Powershell version 5.1 on the endpoint as well as my laptop.

Also, I would like to eventually determine whether a particular windows process is running or stopped in at least 5 different machines, take that info and update a single dashboard. I have managed to do this locally with 1 PC. Thanks

So, before the Powershell Universal hat…

What is the use case for this?? Having the FREE version on the public internet is a terrible idea.

Second, you said you don’t have to worry about port forwarding and that it has a public IP… Does this mean it’s in the DMZ? Can you reach the admin console over the internet?

If you can reach the admin console over the internet, then please, keep in mind you have an open front door to this system if anyone finds that IP is responding on that port and looks up PSU docs. From there they can run anything they want on that system, and possibly install software extremely easily that can compromise other systems.

First, thank you so much for taking the time to answer a noob.

Second, the use case is for my personal development. Because if I can get this working, I’ll have the confidence to integrate PSU into my current workflow.

Third, the free version is only free version till It can’t be. If that’s your answer to my problem, then that’s the fix.

Fourth, It’s only open while I test. I find it useful not to have too many safeguards like firewalls and authentications while I troubleshoot on foreign territory.

Thanks again for the help!

I recommend going the other way. Any job you have is (should) require you to work with a product secured, then punching holes until it works. Now’s the time to get into that mindset and gain experience doing so. Yes, it’s inconvenient having pesky firewalls and authentication while testing, but that is a necessity in today’s world.

In any case, can you access the admin console over the internet?

Thanks for the advice I’ll keep that in mind moving forward. The machine is in a VM. Maybe that’s why I’m having issues? Forgot to mention that detail.

When you say access the console is that by entering the ip followed by the port (5000)?

If so, I tried it from home and it doesn’t connect… I can ping the ip though. I have used a dashboard in the past and could access it from home, so I assumed using the desktop version should give me the same access. Do I have something disabled to access remote on the desktop version perhaps?

I can access the console from within the endpoint using local host:5000

You’re trying to remotely access a dashboard built in Desktop mode? Can’t be done.

Desktop mode runs as the current user as a regular desktop application. It starts the PowerShell Universal web server. The server only listens on localhost. You will not be able to change security settings for the server.

Ah. So, the API I created to run a script to get-process of something on the endpoint can’t be accessed from outside the network? Is that right?

That would be correct. You will need to install the regular version of PSU to access it externally.

Ok that makes sense. Thanks for your help.