CURL script on Powershell to get a Response from HTTPS URL and also want to feed Username/Password

5.2k Views Asked by At

I am new to CURL and facing problems while writing a script to get a response from HTTPS URL.

Its failing at singleSignOn.

Basic command I am using is:

curl -UseBasicParsing https://abc.xyz.com.au -UseDefaultCredentials

Can someone please help with pointers how to force SSO on CURL while doing a check on HTTPS URL?

1

There are 1 best solutions below

0
Adam On

In Powershell Curl is really an alias for Invoke-WebRequest.

If you're new to this commandlet, start easy. Try using it with Google:

Invoke-WebRequest -Uri 'https://www.google.com'

Authentication is a little tricker. If the site uses basic authentication, you can use something like the following:

$credential= Get-Credential
Invoke-WebRequest -Uri 'https://foo.com' -Credential $credential

Depending on the application, you might have to construct the basic authentication headers yourself. There is a nice explanation of that in the post Use Invoke-WebRequest with a username and password for basic authentication on the GitHub API

If the single-sign-on piece is using redirection, that's a different animal. You can use the Headers property on the response object to find the URL you're being redirected to. Jim McNatt has a nice article talking about that.