如何在 Powershell 中发出经过身份验证的 Web 请求? [英] How to make an authenticated web request in Powershell?
本文介绍了如何在 Powershell 中发出经过身份验证的 Web 请求?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在 C# 中,我可能会这样做:
In C#, I might do something like this:
System.Net.WebClient w = new System.Net.WebClient();
w.Credentials = new System.Net.NetworkCredential(username, auth, domain);
string webpage = w.DownloadString(url);
是否有 Powershell 版本,或者我应该直接拨打 CLR?
Is there a Powershell version of this, or should I just call through to the CLR?
推荐答案
PowerShell 几乎完全相同.
The PowerShell is almost exactly the same.
$webclient = new-object System.Net.WebClient
$webclient.Credentials = new-object System.Net.NetworkCredential($username, $password, $domain)
$webpage = $webclient.DownloadString($url)
这篇关于如何在 Powershell 中发出经过身份验证的 Web 请求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文