0

I have been working with Powershell all day, playing with proxy settings and related. A POST request that once worked earlier in the day, is now stating a very bizarre error:

The request:

$tenantId = '8331e1..........'

$client_id = 'a3b869ef................
$client_secret = '0w;m$................'


#************ GET AAD TOKEN ************

$url = "https://login.microsoftonline.com/" + $tenantId + "/oauth2/token"

$body = @{
    grant_type = 'client_credentials'
    client_id = $client_id
    client_secret = $client_secret
    resource = 'https://dev.azuresynapse.net'
}

$GetAADResult = Invoke-WebRequest -Method 'Post' -Uri $url -Body $body

$GetAAD_Content_JSON = $GetAADResult.Content | ConvertFrom-Json

$access_token = $GetAAD_Content_JSON.access_token

# print access_token
$access_token

This used to provide a simple token as a response, but now it is returning the error:

Invoke-WebRequest : The remote name could not be resolved: 'http'
At line:24 char:17
+ ... GetAADResult = Invoke-WebRequest -Method 'Post' -Uri $url -Body $body
+                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Invoke-WebRequest], WebException
    + FullyQualifiedErrorId : System.Net.WebException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand
 
ConvertFrom-Json : Cannot bind argument to parameter 'InputObject' because it is null.
At line:26 char:48
+ $GetAAD_Content_JSON = $GetAADResult.Content | ConvertFrom-Json
+                                                ~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [ConvertFrom-Json], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.ConvertFromJsonCommand

I do not know what needs to change to get this functionating again, it appears PowerShell is looking for a proxy setting in every request...? Anny ideas?

Sauron
  • 6,399
  • 14
  • 71
  • 136

1 Answers1

1

I ended up undoing these steps: https://spaghettidba.com/2017/12/19/recovering-the-psgallery-repository-behind-a-corporate-proxy/

Sauron
  • 6,399
  • 14
  • 71
  • 136