需要有关invoke-webrequest cmdlet的帮助 [英] Need help with invoke-webrequest cmdlet

查看:163
本文介绍了需要有关invoke-webrequest cmdlet的帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我正在尝试使用powershell cmdlet invoke-webrequest来访问一个转到"睡眠"大约几分钟后,我正在尝试使用powershell编写一个脚本来访问网站,就像每隔10分钟一样,以便在缓存中保持活动状态。



这是我到目前为止所得到的,但由于某种原因它不起作用,它更多地围绕用户名和密码的格式,因为我必须使用UNP:


PS C:\\ \\> $ r = Invoke-WebRequest https://www.DomainName.com/

$ r.Forms [ 0] .Name =" UserName@DomainName.com " b
$ r.Forms [0] .Password = " MyPassword"

Invoke-RestMethod https://www.DomainName.com -Body $ r



关于如何使这项工作的任何想法?



提前致谢。






Mohsen Almassud

解决方案

你不能混用两种方法。


用于身份验证的表单不能用作服务。


Invoke-WebRequest -Credential


OR


Invoke-RestMethod -Credential


如果网站使用高级方法,也许你无法进行身份验证。


假设基于表单的身份验证,您需要触发提交表单的事件。


hi all,

I am trying to use powershell cmdlet invoke-webrequest to access a website that goes to "sleep" after about minutes, and I am trying to write a script using powershell to access the site like every 10 minutes to keep it alive in cache.

this is what I got so far but it's not working for some reason and it's more around the format of the user name and password, because I have to use UNP:

PS C:\> $r = Invoke-WebRequest https://www.DomainName.com/
$r.Forms[0].Name = "UserName@DomainName.com"
$r.Forms[0].Password = "MyPassword"
Invoke-RestMethod https://www.DomainName.com -Body $r

any ideas on how to make this work?

Thanks in advance.


Mohsen Almassud

解决方案

YOu cannot mix two method.

A form that is for authentication cannot be used as a service.

Invoke-WebRequest -Credential

OR

Invoke-RestMethod -Credential

Perhaps you cannot authenticate if site uses advanced methods.

Assuming forms based authentication you will need to trigger the event that submits the form.


这篇关于需要有关invoke-webrequest cmdlet的帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆