Answer the question
In order to leave comments, you need to log in
How to implement domain authorization in Powershell?
There is a resource at the entrance to which a domain authorization window opens (the standard Windows authorization window), I need to download a file from this resource using PowerShell, having previously authorized it accordingly. tell me how it can be implemented?
Tried like this:
$user = 'login'
$pass = 'password'
$download_url = "https://...."
$local_path = "C:\Temp\monitor.csv"
$secure = $pass | ConvertTo-SecureString -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential($user, $secure)
$parce = Invoke-WebRequest -Uri $download_url -Credential $cred
$WebClient = New-Object System.Net.WebClient
$WebClient.DonloadFile($download_url, $local_path)
Answer the question
In order to leave comments, you need to log in
Thank you all, it turned out to be implemented through default authorization and run the script through the scheduler with the necessary credentials
there is no Convert-SecureString command. an error should be thrown. try ConvertTo-SecureString.
Try running Invoke-WebRequest -Uri $download_url -Credential(Get-Credential)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question