Home » c# » c# – Get Windows authentication and pass around?

c# – Get Windows authentication and pass around?

Posted by: admin February 21, 2020 Leave a comment

Questions:

How to convert the following PowerShell code to C#?

$cred = Get-Credential # User enters logon/password. What's the C# code?

$url = "$Api/build/builds?api-version=5.1" # Azure DevOps server (on premise) rest api
Invoke-RestMethod $url -Credential $cred

Ideally, $cred can be acquired from the user’s Windows login (instead of prompting the user to enter the username and password (Get-Credential)).

How to&Answers: