首页 \ 问答 \ Powershell调用webrequest无法正常工作(Powershell invoke-webrequest not working)

Powershell调用webrequest无法正常工作(Powershell invoke-webrequest not working)

我有一个Powershell脚本,应该对一个站点运行一个Invoke-WebRequest 。 我想将此脚本与PRTG网络监视器一起使用,以确保Web服务器正常运行。

目前,该脚本可以在本地计算机上运行,​​也可以在探针服务器上使用我的域凭据运行。 但是,使用PRTG使用的本地管理凭据登录时,它不会运行。

我把它缩小到一条线,

Invoke-WebRequest $uri -Method POST -Body $body -TimeoutSec 10

看来,无论出于何种原因,使用此帐户时, Invoke-WebRequest将无法运行。 运行该行时,它不会产生任何内容,也不会产生错误,警告或输出。 $uri$body变量也已定义。

即使我使用本地管理员PRTG帐户登录探测服务器并以另一个用户身份运行Powershell(使用我自己的凭据),它仍然无法生成任何内容。

为什么本地管理员帐户无法运行Invoke-WebRequest ? 这是在带有PSVersion 4.0的Windows Server 2012R2上发生的。


I have a Powershell script that is supposed to run an Invoke-WebRequest against a site. I want to use this script with PRTG Network Monitor to ensure that a web server is up and running properly.

Currently, the script works running from my local machine as well as running with my domain credentials on the probe server. However, it doesn't run when logged in with the local admin credentials which is what PRTG uses.

I've narrowed it down to a single line,

Invoke-WebRequest $uri -Method POST -Body $body -TimeoutSec 10

It appears that for whatever reason, when using this account, Invoke-WebRequest will not work. When running that line, it doesn't produce anything, no error, warning, or output. Both $uri and $body variables are already defined as well.

Even if I'm logged into the probe server with the local admin PRTG account and run Powershell as another user (using my own credentials) it still fails to produce anything.

Why would a local admin account not be able to run Invoke-WebRequest? This is happening on a Windows Server 2012R2 with PSVersion 4.0.


原文:https://stackoverflow.com/questions/50258933
更新时间:2022-07-25 08:07

最满意答案

它变成了这个:

void sample_breaks() {
    double partOfSecondAVFoundationNumber = 2 * = 1.0/30.0;;
}

经过预处理。 所以你会发现错误。

改成

#define ONE_FRAME_OF_30FPS_2 (1.0/30.0)

代替。


It becomes this:

void sample_breaks() {
    double partOfSecondAVFoundationNumber = 2 * = 1.0/30.0;;
}

after preprocessing. So you would expect an error.

Change to

#define ONE_FRAME_OF_30FPS_2 (1.0/30.0)

instead.

相关问答

更多

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)