Last active
February 21, 2022 13:25
-
-
Save jimbo8098/1f34bc68e17eaba028b7ab4e8fa639b8 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# $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