A
A
Anton Nagaets2017-02-06 09:30:59
PowerShell
Anton Nagaets, 2017-02-06 09:30:59

How to make automatic windows authorization on powershell?

There is a certain resource from which it is necessary to obtain information. The resource has Windows authorization, and it is rather peculiar. Another "feature" of this resource is the inclusion of a resource for a given time interval. For authorization, I use the following script; its drawback is that it simply inserts credentials into the form and you need to confirm them manually, i.e. click on the "OK" button:
f8fadb813813426f8af99dccbd80c86d.png

#Учетные данные 
$user = 'login'
$pass = 'superpass'
$secureStringPwd = $pass | ConvertTo-SecureString -AsPlainText -Force 
$credis = New-Object System.Management.Automation.PSCredential -ArgumentList $user, $secureStringPwd
#Куда подключаемся
$source = "https://Resource/"
#Подключаемся к ресурсу
$parce = Invoke-WebRequest -Uri $source -Credential $credis 
#пошел запрос к серверу и тут от нас требуют подтверждение учетных данных

I can not find information on how to make an automatic connection so that I can normally throw it into the shader.
It is pointless to recommend other tools because you can’t install anything else on the computer and you have to get out with the built-in tools.
================================================= ===========================
UPD > After digging for 2 days, I realized that the problem is not in authorization. The cmdlet works great. The problem is with certificates. They are in the repository and additionally in the script it is worth ignoring problematic certificates. Everything works fine in the browser. As expected. Certificate in storage, authorization only. There are no errors or warnings in the form of a certificate error page. Empirically, it was obtained just that for each certificate call (which is ignored), an authorization attempt occurs. If you click on "cancel", then after a few "cancellations" normal authorization occurs through invoke-webrequest.
I'm already starting to hate government agencies in which services work this way.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Anton Nagaets, 2017-02-08
@gr1mm3r

The question is closed. There was a problem with certificates, FQDNs and redirects on the remote server.

A
azarij, 2017-02-07
@azarij

What does this resource look like in the browser? also asks for a password through Windows?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question