- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Powershell Error using GET request: Cannot connect to remote server
This is based on the Postman documentation and some other stuff I saw online. I am able to use the same API key and uri to perform a get through Postman.
For automation reasons I would like to use Powershell. This is a piece of a bigger script that generates a random password and makes an update using a PUT. I have simplified it to what is seen below in the screenshot (including making it a GET) to make it easier to diagnose (hopefully).
Also, if the uri has https, then do I need the tls1.2 line (line 3)?
Thanks.
Solved! Go to solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Your syntax is right.
That should give you back an HTTP 200 along with some other data.
It definitely seems like the connection is getting blocked somewhere.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This appears to be a fundamental issue, it is saying it is unable to connect to https://api.meraki.com/
Can I web browser on that machine connect? When I try I get redirected to the Meraki dashboard login (so this should happen for you as well).
You don't have an internal proxy server or something you need to use to connect to the Internet?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for the response.
api.meraki.com redirects to the dashboard from a browser on the same machine.
I don't believe there is a proxy. The same operation can be done from Postman, but powershell gives the error shown prior.
I also tried using nXXX.meraki.com through powershell (just to try other things) and it was unsuccessful as well (with the same error).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Are you able to make a request to google.com? (aka, prove you can access something else on the Internet)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Is this sufficient. Maybe powershell is blocked by something? Not sure if my syntax is even correct.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Your syntax is right.
That should give you back an HTTP 200 along with some other data.
It definitely seems like the connection is getting blocked somewhere.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yeah, Powershell was blocked by CarbonBlack.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you both for your help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I personally haven't set the TLS version in my scripts.
Not sure whether that would cause a problem or not.
As @PhilipDAth mentioned - the error could be indicating a connection problem to the API backend.
For reference, this is a script that I use quite frequently without issue.
Meraki/Meraki Update Switchports.ps1 at main · Brash92/Meraki (github.com)
