小编use*_*814的帖子

powershell http get 不使用代理

我有脚本来获取 HTTP 内容,我需要 baypass 代理(直接连接到网络服务器 IP)。是否可以不更改 Windows 中的寄存器?此代码正在通过系统中定义的代理。谢谢你的建议

此致。

$url='https://10.10.10.10/check';
$webClient = new-object System.Net.WebClient;
$output = $webClient.DownloadString($url)
Run Code Online (Sandbox Code Playgroud)

powershell proxy

3
推荐指数
1
解决办法
9291
查看次数

使用来自certstore的客户端证书的PowerShell HTTPS GET

我正在尝试找到使用客户端证书通过HTTPS检查Web内容的简便方法。我有VBScript,其中定义了客户端证书,跳过了服务器证书并定义了我要搜索的内容(字符串“ running”)。我的意思是将脚本重写为PowerShell。

这是VBScode:

device = "10.10.10.10"
link = "5001/test"
Set Http = CreateObject("WinHttp.WinHttpRequest.5.1")
Http.SetClientCertificate "LOCAL_MACHINE\MY\test"
Http.Option(4) = 256 + 512 + 4096 + 8192 
Http.Open "GET", "https://" & device & ":" & link, false
Http.Send
output = Http.ResponseText
If InStr(1,output,"running") Then
wscript.echo "OK"
Else
wscript.echo "Error"
End If
Set Http = Nothing
Run Code Online (Sandbox Code Playgroud)

这是获取HTTP Web内容(而不是https)的Powershell语法:

$page = (New-Object System.Net.WebClient).DownloadString("http://10.10.10.10:5001/test")
"$page"
Run Code Online (Sandbox Code Playgroud)

这是使用.CRT文件获取HTTPS竞争的Powershell语法(但不是来自CERTSTORE)

[System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}
$cert = [System.Security.Cryptography.X509Certificates.X509Certificate2]::CreateFromCertFile("C:\Cert\test.crt")
$url = "https://10.10.10.10:5001/test"
$web = [System.Net.WebRequest]::Create($url)
$web.ClientCertificates.Add($Cert)
Run Code Online (Sandbox Code Playgroud)

这是我最新获得网络竞争的尝试。没有成功

#ignore untrusted certificate
[System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true} …
Run Code Online (Sandbox Code Playgroud)

powershell https get certificate

1
推荐指数
1
解决办法
2万
查看次数

标签 统计

powershell ×2

certificate ×1

get ×1

https ×1

proxy ×1