Authorization Type Basic in powershell script

55 views Asked by At

How to pass set below Postman Authorization Type Basie Username and password values in Power shell script?

enter image description here

$username = "laxjeurkaie"

$password = "pwdeoros243" | ConvertTo-SecureString -asPlainText -Force
$credential = New-Object System.Management.Automation.PSCredential($username,$password)

ECHO $credential

$headers = @{}
$headers.Add("Authorization", $Authorization)
$headers.Add("Accept", "application/json")

ECHO $headers

$response = -1
$response = Invoke-WebRequest -Uri $myUrl -Method GET -Credential $credential -Headers $headers 

ECHO $response
0

There are 0 answers