Skip to content

Instantly share code, notes, and snippets.

@dky
Created February 6, 2025 22:36
Show Gist options
  • Save dky/0d8cc9aa0245718d0baaba8afc5b0a63 to your computer and use it in GitHub Desktop.
Save dky/0d8cc9aa0245718d0baaba8afc5b0a63 to your computer and use it in GitHub Desktop.
# Make sure you have a valid Kerberos ticket using kinit or equivalent
$uri = "https://your-service.example.com"
# Get the Kerberos authentication token using the System.Net.HttpListenerContext
$kerberosToken = [System.Net.CredentialCache]::DefaultNetworkCredentials
# Make the web request with the Authorization header set to the Kerberos token
$response = Invoke-WebRequest -Uri $uri -Headers @{
"Authorization" = "Negotiate $($kerberosToken.GetCredential($uri, 'Negotiate').Password)"
}
# Output response
$response.Content
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment