Skip to content

Instantly share code, notes, and snippets.

@raj-arun
Last active July 18, 2019 15:33
Show Gist options
  • Save raj-arun/d505b9cdf1ef17425ad2ccb2fa088cba to your computer and use it in GitHub Desktop.
Save raj-arun/d505b9cdf1ef17425ad2ccb2fa088cba to your computer and use it in GitHub Desktop.
Encrypt Username and Password
#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