Last active
July 18, 2019 15:33
-
-
Save raj-arun/d505b9cdf1ef17425ad2ccb2fa088cba to your computer and use it in GitHub Desktop.
Encrypt Username and Password
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Read user name , password and wsdl endpoint | |
$loginData = Get-Content -Raw -Path 'loginDetails.json' | ConvertFrom-Json | |
#Encrypt the username and password | |
$pair="$($loginData.biuser):$($loginData.bipwd)" | |
$encodedCreds = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($pair)) | |
$basicAuthValue = "Basic $encodedCreds" | |
#Create the header for Web Service Request | |
[Net.ServicePointManager]::SecurityProtocol = "tls12" | |
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]" | |
$headers.Add('SOAPAction','') | |
$headers.Add('Authorization',$basicAuthValue) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment