Skip to content

Instantly share code, notes, and snippets.

@jimbo8098
Last active February 21, 2022 13:25
Show Gist options
  • Save jimbo8098/1f34bc68e17eaba028b7ab4e8fa639b8 to your computer and use it in GitHub Desktop.
Save jimbo8098/1f34bc68e17eaba028b7ab4e8fa639b8 to your computer and use it in GitHub Desktop.
# $ntlmUsername = "domain\username" formatted account name
# $ntlmPassword = "password"
# $urlToGet = "https://google.com"
$ntlmCred = New-Object System.Net.NetworkCredential($ntlmUsername,$ntlmPassword)
$getArr = @($urlToGet)
$client = New-Object System.Net.WebClient
$client.Credentials = $ntlmCred
try {
$data = $client.OpenRead($getArr)
} catch [System.Management.Automation.MethodInvocationException] {
Write-Error "An error occurred while connecting"
Write-Host $PSItem.TargetObject
Write-Host $PSItem.ErrorDetails
Write-Host $PSItem.Exception
}
$r = New-Object System.IO.StreamReader($data)
$str = $r.ReadToEnd()
$r.Dispose()
Write-Host $str
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment