PowerShell Error: Invoke-RestMethod: Unable to connect to the remote server

427 Views Asked by At

I'm running the following script to retrieve the credentials of a service account from conjur (cyberark product)

# Create a dictionary to store headers
  $headers = New-Object   "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Authorization", "Token token=")

# Define the URL
  $url = "https://dap- follower.aws.corpads.local/secrets/conjurprod/variable/vault/LOB_User1/SRV_HrzCloudEng/[email protected]/password"

# Perform an HTTP GET request
  $response = Invoke-RestMethod -Uri       $url -Method GET -Headers $headers

# Convert the response to JSON
  $response | ConvertTo-Json

But after executing it in PS (as an administrator) it is giving me following error:

Invoke-RestMethod: Unable to connect to the remote server At line:3 char:13

+ Sresponse Invoke-RestMethod https://dap-follower aws. corpads.local/...

+CategoryInfo: InvalidOperation: (System.Net.HttpWebRequest: HttpWebRequest) [Invoke-RestMethod], WebException + FullyQualifiedErrorId : WebCmdletWebResponseException, Microsoft. Power Shell.Commands. InvokeRestMethodCommand
0

There are 0 best solutions below