[英]How to use Invoke-Webrequest to download Salesforce report
[英]How to use PowerShell invoke-webrequest with Windows Authentication and Username\Password
當我運行它的 Windows 服務有權調用 web 服務時,以下 PowerShell invoke-webrequest 對我有用。 然而,情況並非總是如此。
我需要能夠使用 Windows 身份驗證,但還需要為呼叫設置帳戶用戶名\\密碼。 有沒有人有一些示例代碼來執行此操作?
Invoke-WebRequest -UseBasicParsing "url" -UseDefaultCredentials -Method GET
您可以將Invoke-WebRequest
模塊的UseDefaultCredentials
屬性設置為true
。 官方文檔鏈接: https : //docs.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/invoke-webrequest? view =powershell-6
$url = "http://yourURL"
$wc = New-Object System.Net.WebClient
$wc.UseDefaultCredentials = $true
$response = $wc.DownloadString($url)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.