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
最满意答案
它变成了这个:
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.
相关问答
更多-
这是一个想法: class BiConverter[T, U, That](val toThat1: T => That, val toThat2: U => That)(implicit val num: Numeric[That]) trait LowPriorityBiConverterImplicits { implicit def subtype[A: Numeric, T <: A, U <: A]: BiConverter[T, U, A] = new BiConverter[T, U, ...
-
首先,没有理由在这里使用内联汇编,简单的解决方案是将此代码编写为普通的汇编语言文件。 您可以在头文件中定义FLASH_APP_START宏,如果需要,可以包含在程序集和C源文件中。 如果您仍想使用内联汇编,那么下一个最简单的解决方案是让编译器为您完成大部分工作,并将汇编语句减少到它不能执行的操作: void ** const flash_vector_table = (void **) FLASH_APP_START; asm volatile ("mov sp, %[stack]\n\t" ...
-
变量(或类型)的大小可以通过以下方式获得: sizeof(variableNameOrTypeName) 如果你在一个给定数组元素的地址之后,例如variableName[42] ,它只是: &(variableName[42]) 没有明确的指针捣乱。 如果要在只有指针的情况下操作实际的double 值 ,则需要取消引用指针。 例如: double xyzzy = 108.0; // this is the VALUE. double *pXyzzy = &xyzzy; // this is ...
-
我只是想了解如何将这个特定的常量设计为在本地使用 然后用一个下划线(=> _PATH=... )作为前缀。 这是指定此名称不是公共API的约定(适用于每种名称 - 模块级别,类别或实例属性等)。 这不会在技术上阻止任何人使用它(就像ALL_UPPER在技术上不会使它成为常量),但只要您尊重这个命名规则,每个pythonista的意图都是明确的,任何人都可以独立使用它。 I just want to understand how will I convey this to other developer th ...
-
如何在外部链接的命名空间范围内定义一个常量double?(How to define a constant double at namespace scope with external linkage?)[2023-09-02]
是,没有 ; 你可以使用extern : [C++11: 3.5/3]: 名称空间范围 (3.3.6)的名称具有 内部链接,如果名称是 显式声明为static的变量,函数或函数模板; 要么, 一个明确声明为 const或constexpr 的变量, 既没有明确声明为extern也没有声明过具有外部链接 ; 要么 匿名工会的数据成员。 所以: namespace foo { extern constexpr double bar() { return 1.23456; } extern co ... -
我会说: - 在C ++ 14中: namespace constant { template
constexpr T PI = T(3.1415926535897932385); } - 在C ++ 11中: namespace constant { constexpr double PI = 3.1415926535897932385; } - 在c + + 03中: namespace constant { static const ... -
在AT&T内联汇编中将float / double设置为常量值(Setting a float/double to a constant value in AT&T inline assembly)[2023-06-12]
由于两个原因,您无法使内联汇编代码可移植到Microsoft的C / C ++编译器。 首先,asm语句的语法太不同了。 微软的编译器需要像asm { mov rax, [rbp + 8] }而不是asm("movq -8(%rbp), %rax\n\t") 。 第二个是Microsoft 64位编译器不支持内联汇编。 所以你不妨正确地使用GCC的扩展语法。 因为它是你的内联组件非常脆弱。 您不能将val -8(%rbp) 。 编译器可能甚至没有把它放在堆栈上。 你也不能假设编译器不介意你丢弃RAX,XMM ... -
目标c:在数学表达式中使用#define常量值(Objective c : Using #define constant values in math expressions)[2022-06-20]
删除分号; 在#define之后: #define WIDTH_OFFSET 6 #define替换它的参数,所以预处理后的表达式变成了 (((myValue - min_value) * 6;) - middle); 正如你所看到的,表达式中间有一个分号,这是一个语法错误。 另一方面,你的其他表情 int offset = myValue - min_value; offset = offset * WIDTH_OFFSET; 不会出现这样的问题,因为在一排中有两个分号 offset = offs ... -
在内联构造函数中访问静态成员时,为什么链接器会失败(Why does linker fail when accessing static member in inline constructor)[2023-12-28]
应该: #ifdef __DLL__ // Defined in DLL-project #define DLLEXPORT __declspec( dllexport ) #else #define DLLEXPORT __declspec( dllimport ) #endif 您可以使用dllimport或dllexport属性声明C ++类。 这些形式意味着导入或导出整个类。 以这种方式导出的类称为可导出类。 文档中的更多信息。 Should be: #ifdef __DLL_ ... -
它变成了这个: 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 ...