Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Powershell:执行Recieve作业时收到拒绝访问错误_Powershell_Nagios - Fatal编程技术网

Powershell:执行Recieve作业时收到拒绝访问错误

Powershell:执行Recieve作业时收到拒绝访问错误,powershell,nagios,Powershell,Nagios,我有一个小的powershell脚本,我希望通过Nagios monitoring执行该脚本,以验证某个目录是否存在是或否。在powershell ISE中调试和/或运行该脚本时,一切正常,并生成所需的结果。通过Nagios调度脚本时,我收到“拒绝访问”错误 脚本中产生错误的行: $testJob = Start-Job -scriptblock {test-path $($args[0])} -credential $ipmamCredentials -argumentlist $ipmamd

我有一个小的powershell脚本,我希望通过Nagios monitoring执行该脚本,以验证某个目录是否存在是或否。在powershell ISE中调试和/或运行该脚本时,一切正常,并生成所需的结果。通过Nagios调度脚本时,我收到“拒绝访问”错误

脚本中产生错误的行:

$testJob = Start-Job -scriptblock {test-path $($args[0])} -credential $ipmamCredentials -argumentlist $ipmamdir
$finished = Wait-Job $testJob
$result = Receive-Job $testJob
Nagios中产生的错误:

Receive-Job : [localhost] There is an error launching the background process. Error reported: Access is denied.
At C:\Program Files\NSClient++\scripts\check_ipmam_drives.ps1:19 char:26
+ $result = Receive-Job <<<< $testJob 
+ CategoryInfo : OpenError: (:) [Receive-Job], PSRemotingTransportException 
+ FullyQualifiedErrorId : PSSessionStateBroken
Receive Job:[localhost]启动后台进程时出错。报告错误:访问被拒绝。
在C:\Program Files\NSClient++\scripts\check\u IPAM\u drives.ps1:19 char:26

+$result=Receive Job运行Nagios的进程是否有权访问您要检查的文件夹?由于启动作业调用中传递的凭据,Nagios应该有权访问该文件夹。这正是我使用Start Job的原因。普通访问用户(包括Nagios)无法直接访问该文件夹。只有特权用户才能访问该文件夹。我假设Nagios是作为服务运行的?更仔细地观察错误,它似乎来自启动作业,表明服务没有足够的权限执行模拟/提升。Nagios服务的“登录”选项卡中的值:在系统启动时使用本地系统帐户自动启动。设置了“允许服务与桌面交互”标志。