Skip to content

Instantly share code, notes, and snippets.

@zhangyuan
Created December 20, 2016 06:21
Show Gist options
  • Select an option

  • Save zhangyuan/acf0a62ad466e084067d07d9f518ea3b to your computer and use it in GitHub Desktop.

Select an option

Save zhangyuan/acf0a62ad466e084067d07d9f518ea3b to your computer and use it in GitHub Desktop.
Send HTTP Request with Credential (HTTP Basic Authentication)
$username = ""
$password = ""
$url = ""
$securePassword = ConvertTo-SecureString $password -AsPlainText -Force
$credential = New-Object System.Management.Automation.PSCredential ($username, $securePassword)
$stream = Invoke-WebRequest -Uri url -Credential $credential
Write-Host $stream.content
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment