0
我試圖通過使用Invoke-WebRequest cmdlet轉換wget調用調用,但我嘗試的代碼導致出現問題。將Wget調用轉換爲PowerShell
wget --no-check-certificate -S -q --header "Accept: application/json" --header='ContentType: application/json' --header="Authorization: Bearer <TOKEN>" -O https://10.107.174.117/itfm-cloud/rest/reports-api/export-csv?name=servers
這是我嘗試使用Invoke-WebRequest,但導致錯誤。
add-type @"
using System.Net;
using System.Security.Cryptography.X509Certificates;
public class TrustAllCertsPolicy : ICertificatePolicy {
public bool CheckValidationResult(
ServicePoint srvPoint, X509Certificate certificate,
WebRequest request, int certificateProblem) {
return true;
}
}
"@
[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy
[System.Net.ServicePointManager]::SecurityProtocol = @("Tls12","Tls11","Tls","Ssl3")
$username = "ebc\cloudadmin"
$password = "are1!" | ConvertTo-SecureString -asPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential($username,$password)
Invoke-WebRequest https://10.107.174.117/itfm-cloud/rest/reports-api/export-csv?name=servers -Credential $cred
誰能幫助?