2013-08-06 4 views
0

Я столкнулся с особой проблемой в PowerShell 2.0. Я не эксперт в области PS, но иногда пишу/редактирую несколько сценариев для работы с инструментом мониторинга Nagios. Обращение в службу поддержки экспертов Nagios. Ваша помощь будет оценена по достоинству.Отсутствует выражение после унарного оператора '-'. На линии: 1 char: 2

Скрипт ExServiceAlert10.ps1 встраивается ниже:

#First, findout if Exchange Management Shell is loaded: 
$snapins = Get-PSSnapin |select name 
$snapincount=0; 
$found = $false 
do 
{ 
$founDName = $snapins[$snapincount].name 
if ($founDName -eq “Microsoft.Exchange.Management.PowerShell.E2010″) 
#Exchange Shell already loaded 
{ 
$found = $True 
break 
} 
$snapincount++} 
while ($snapincount -lt $snapins.Count) 
if ($found -ne $True) 
{ 
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010 
} 
# Create variables 
$status = 0 
$desc = “” 
# Get Service Health 
Test-ServiceHealth | ForEach-Object { 
$main = “`n" + "Role: " + $_.Role + "`n” + “Status: ” + $_.RequiredServicesRunning + “`n” 
if ($_.RequiredServicesRunning -eq “True”){ 
$array = $_.ServicesRunning 
$runningsvcs = “Services running:” 
foreach ($svc in $array){ 
$runningsvcs = $runningsvcs + ” ” + $svc 
} 
$desc += $main +$runningsvcs + “`n” 
}else{ 
$status = 1 
$array = $_.ServicesNotRunning 
$notrunning = “Services Not running” 
foreach ($svc in $array){ 
$notrunning = $notrunning + ” ” + $svc 
} 
$desc += $main + $notrunning 
} 
} 
if ($status -eq 1){ 
echo “Critical – Exchange Services Alert $desc” 
exit 2 
}else{ 
echo “OK – Exchange Services Alert $desc” 
exit 0 
} 

Скрипт работает нормально и не показывает ошибку, если я непосредственно выполнить его в PowerShell, как это:

PS C:\Windows\system32> D:\ExServiceAlert10.ps1 

Но это показывает, ошибка, когда я выполняю его через cmd или из Nagios NSClient ++ следующим образом:

Нормальная команда Выполнение запроса: (Сценарий размещен в D :) D:> echo. \ Ex ServiceAlert10.ps1; exit $ LastExitCode | powershell.exe -command -

С Nagios NSClient ++ исполнения через check_nrpe: (Script помещена в каталоге NSClient Script)

cmd /c echo scripts\ExServiceAlert10.ps1; exit $LastExitCode | powershell.exe -command – 

Ошибки я получаю это:

Missing expression after unary opearator ‘-’. 

At line:1 char:2 
+ – <<<< 
+ CategoryInfo : ParseError: (-:String) [], ParentContainsErrorRecordException 
+FullyQualifiedErrorId : MissingExpressionAfterOperator 

Я выполнение этот скрипт в PowerShell 2.0 и пробовал различные методы отладки для решения этой проблемы на прошлой неделе без успеха.

Вот некоторые данные из моего NSClient ++ conf. файл NSC.ini для других скриптов PS, которые отлично работают без каких-либо проблем.

exch_mail_flow10=cmd /c echo scripts\ExchMailFlow10.ps1; exit $LastExitCode | powershell.exe -command - 
exch_mailboxhealth10=cmd /c echo scripts\ExMailboxhealth10.ps1; exit $LastExitCode | powershell.exe -command – 

Даже сообщили странствующий сценарий (ExServiceAlert10.ps1) работает отлично в моей тестовой системе с этим дополнительным тиром в командной строке, но не работает вообще ни в одном из в Prod. система. Все версии PS 2.0.

Я думаю, что либо я должен включить/отключить некоторые настройки среды PS на этих странных Prod. систем или избежать чего-либо внутри скрипта (подозревая символы новой строки - «n backtick n»). Я не понимаю, почему он сообщает строку: 1 и char: 2, которая является ничем иным, как строкой комментария в скрипте.

Я видел эту ошибку, о которой сообщают несколько других, и их проблема была решена после обновления их PS до версии 2.0. Мой уже 2.0 и не знает, что делать дальше.

NSC.ini файл:

;Nagios agent for BR 1.8 dated Aug 30, 2012. The MSI is updated to 0.3.9 version of nsclient++ and is re-packaged for silent installation. Install.vbs is removed. 
[modules] 
NRPEListener.dll 
NSClientListener.dll 
NSCAAgent.dll 
CheckWMI.dll 
FileLogger.dll 
CheckSystem.dll 
CheckDisk.dll 
CheckEventLog.dll 
CheckHelpers.dll 
CheckExternalScripts.dll 
;# NSCLIENT++ MODULES 
;# A list with DLLs to load at startup. 
; You will need to enable some of these for NSClient++ to work. 
; ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! 
; *                * 
; * N O T I C E ! ! ! - Y O U H A V E T O E D I T T H I S * 
; *                * 
; ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! 
;FileLogger.dll 
;CheckSystem.dll 
;CheckDisk.dll 
;NSClientListener.dll 
;NRPEListener.dll 
;SysTray.dll 
;CheckEventLog.dll 
;CheckHelpers.dll 
;CheckWMI.dll 
;CheckNSCP.dll 
; 
; Script to check external scripts and/or internal aliases. 
;CheckExternalScripts.dll 
; 
; NSCA Agent if you enable this NSClient++ will talk to NSCA hosts repeatedly (so dont enable unless you want to use NSCA) 
;NSCAAgent.dll 
; 
; LUA script module used to write your own "check deamon". 
;LUAScript.dll 
; 
; RemoteConfiguration IS AN EXTREM EARLY IDEA SO DONT USE FOR PRODUCTION ENVIROMNEMTS! 
;RemoteConfiguration.dll 
; Check other hosts through NRPE extreme beta and probably a bit dangerous! :) 
;NRPEClient.dll 
; Extreamly early beta of a task-schedule checker 
;CheckTaskSched.dll 
[crash] 
; Archive crash dump files if a crash is detected 
;archive=1 
; Submit crash reports to a crash report server (this overrrides archive) 
;submit=0 
; Restart service if a crash is detected 
;restart=1 
[Settings] 
;# OBFUSCATED PASSWORD 
; This is the same as the password option but here you can store the password in an obfuscated manner. 
; *NOTICE* obfuscation is *NOT* the same as encryption, someone with access to this file can still figure out the 
; password. Its just a bit harder to do it at first glance. 
;obfuscated_password=Jw0KAUUdXlAAUwASDAAB 
; 
;# PASSWORD 
; This is the password (-s) that is required to access NSClient remotely. If you leave this blank everyone will be able to access the daemon remotly. 
;password=secret-password 
; 
;# ALLOWED HOST ADDRESSES 
; This is a comma-delimited list of IP address of hosts that are allowed to talk to the all daemons. 
; If leave this blank anyone can access the deamon remotly (NSClient still requires a valid password). 
; The syntax is host or ip/mask so 192.168.0.0/24 will allow anyone on that subnet access 
;allowed_hosts=127.0.0.1/32 
; 
;# USE THIS FILE 
; Use the INI file as opposed to the registry if this is 0 and the use_reg in the registry is set to 1 
; the registry will be used instead. 
use_file=1 
allowed_hosts=163.228.10.52 
; 
; # USE SHARED MEMORY CHANNELS 
; This is the "new" way for using the system tray based on an IPC framework on top shared memmory channels and events. 
; It is brand new and (probably has bugs) so dont enable this unless for testing! 
; If set to 1 shared channels will be created and system tray icons created and such and such... 
;shared_session=0 
[log] 
;# LOG DEBUG 
; Set to 1 if you want debug message printed in the log file (debug messages are always printed to stdout when run with -test) 
;debug=1 
; 
;# LOG FILE 
; The file to print log statements to 
;file=nsclient.log 
; 
;# LOG DATE MASK 
; The format to for the date/time part of the log entry written to file. 
;date_mask=%Y-%m-%d %H:%M:%S 
; 
;# LOG ROOT FOLDER 
; The root folder to use for logging. 
; exe = the folder where the executable is located 
; local-app-data = local application data (probably a better choice then the old default) 
;root_folder=exe 
[NSClient] 
;# ALLOWED HOST ADDRESSES 
; This is a comma-delimited list of IP address of hosts that are allowed to talk to NSClient deamon. 
; If you leave this blank the global version will be used instead. 
;allowed_hosts= 
; 
;# NSCLIENT PORT NUMBER 
; This is the port the NSClientListener.dll will listen to. 
port=12489 
; 
;# BIND TO ADDRESS 
; Allows you to bind server to a specific local address. This has to be a dotted ip adress not a hostname. 
; Leaving this blank will bind to all avalible IP adresses. 
;bind_to_address= 
; 
;# SOCKET TIMEOUT 
; Timeout when reading packets on incoming sockets. If the data has not arrived withint this time we will bail out. 
socket_timeout=60 
[NRPE] 
;# NRPE PORT NUMBER 
; This is the port the NRPEListener.dll will listen to. 
port=5666 
; 
;# COMMAND TIMEOUT 
; This specifies the maximum number of seconds that the NRPE daemon will allow plug-ins to finish executing before killing them off. 
command_timeout=60 
; 
;# COMMAND ARGUMENT PROCESSING 
; This option determines whether or not the NRPE daemon will allow clients to specify arguments to commands that are executed. 
allow_arguments=1 
; 
;# COMMAND ALLOW NASTY META CHARS 
; This option determines whether or not the NRPE daemon will allow clients to specify nasty (as in |`&><'"\[]{}) characters in arguments. 
allow_nasty_meta_chars=1 
; 
;# USE SSL SOCKET 
; This option controls if SSL should be used on the socket. 
;use_ssl=1 
; 
;# BIND TO ADDRESS 
; Allows you to bind server to a specific local address. This has to be a dotted ip adress not a hostname. 
; Leaving this blank will bind to all avalible IP adresses. 
; bind_to_address= 
; 
;# ALLOWED HOST ADDRESSES 
; This is a comma-delimited list of IP address of hosts that are allowed to talk to NRPE deamon. 
; If you leave this blank the global version will be used instead. 
;allowed_hosts= 
; 
;# SCRIPT DIRECTORY 
; All files in this directory will become check commands. 
; *WARNING* This is undoubtedly dangerous so use with care! 
;script_dir=scripts\ 
; 
;# SOCKET TIMEOUT 
; Timeout when reading packets on incoming sockets. If the data has not arrived withint this time we will bail out. 
;socket_timeout=30 
[Check System] 
;# CPU BUFFER SIZE 
; Can be anything ranging from 1s (for 1 second) to 10w for 10 weeks. Notice that a larger buffer will waste memory 
; so don't use a larger buffer then you need (ie. the longest check you do +1). 
;CPUBufferSize=1h 
; 
;# CHECK RESOLUTION 
; The resolution to check values (currently only CPU). 
; The value is entered in 1/10:th of a second and the default is 10 (which means ones every second) 
;CheckResolution=10 
; 
;# CHECK ALL SERVICES 
; Configure how to check services when a CheckAll is performed. 
; ...=started means services in that class *has* to be running. 
; ...=stopped means services in that class has to be stopped. 
; ...=ignored means services in this class will be ignored. 
;check_all_services[SERVICE_BOOT_START]=ignored 
;check_all_services[SERVICE_SYSTEM_START]=ignored 
;check_all_services[SERVICE_AUTO_START]=started 
;check_all_services[SERVICE_DEMAND_START]=ignored 
;check_all_services[SERVICE_DISABLED]=stopped 
[External Script] 
;# COMMAND TIMEOUT 
; This specifies the maximum number of seconds that the NRPE daemon will allow plug-ins to finish executing before killing them off. 
;command_timeout=60 
; 
;# COMMAND ARGUMENT PROCESSING 
; This option determines whether or not the NRPE daemon will allow clients to specify arguments to commands that are executed. 
allow_arguments=1 
; 
;# COMMAND ALLOW NASTY META CHARS 
; This option determines whether or not the NRPE daemon will allow clients to specify nasty (as in |`&><'"\[]{}) characters in arguments. 
allow_nasty_meta_chars=1 
; 
;# SCRIPT DIRECTORY 
; All files in this directory will become check commands. 
; *WARNING* This is undoubtedly dangerous so use with care! 
;script_dir=c:\my\script\dir 
[Script Wrappings] 
vbs=cscript.exe //T:30 //NoLogo scripts\lib\wrapper.vbs %SCRIPT% %ARGS% 
ps1=cmd /c echo scripts\%SCRIPT% %ARGS%; exit($lastexitcode) | powershell.exe -command - 
bat=scripts\%SCRIPT% %ARGS% 
[External Scripts] 
;check_es_long=scripts\long.bat 
;check_es_ok=scripts\ok.bat 
;check_es_nok=scripts\nok.bat 
;check_vbs_sample=cscript.exe //T:30 //NoLogo scripts\check_vb.vbs 
;check_powershell_warn=cmd /c echo scripts\powershell.ps1 | powershell.exe -command - 
dfsdiag_cmd=dfsdiag $ARG1$ $ARG2$ 
dfsrdiag_cmd=dfsrdiag $ARG1$ $ARG2$ 
check_log=perl scripts\check_log2.pl -l "$ARG1$" -p1 "$ARG2$" -p2 "$ARG3$" -p3 "$ARG4$" -p4 "$ARG5$" 
check_log2=perl scripts\check_log2.pl -l "$ARG1$" -t "$ARG2$" -p1 "$ARG3$" -p2 "$ARG4$" -p3 "$ARG5$" -p4 "$ARG6$" 
check_log3=perl scripts\check_log2.pl -l "$ARG1$" -t "$ARG2$" -n "$ARG3$" -p1 "$ARG4$" -p2 "$ARG5$" -p3 "$ARG6$" -p4 "$ARG7$" 
check_vlog=perl scripts\check_vlog.pl -l "$ARG1$" -t "$ARG2$" -p1 "$ARG3$" -p2 "$ARG4$" -p3 "$ARG5$" -p4 "$ARG6$" 
check_vlog2=perl scripts\check_vlog.pl -l "$ARG1$" -t "$ARG2$" -p1 "$ARG3$" -p2 "$ARG4$" -p3 "$ARG5$" -p4 "$ARG6$" -w "$ARG7$" -c "$ARG8$" 
check_log_mp1=perl scripts\check_log_mp.pl -l "$ARG1$" -p "$ARG2$" -t "$ARG3$" -w $ARG4$ -c $ARG5$ 
check_log_mp2=perl scripts\check_log_mp.pl -l "$ARG1$" -p "$ARG2$" -t "$ARG3$" -n "$ARG4$" -w $ARG5$ -c $ARG6$ 
check_log_mp3=perl scripts\check_log_mp.pl -l "$ARG1$" -p "$ARG2$" -t "$ARG3$" -n "$ARG4$" -s "$ARG5$" -w $ARG6$ -c $ARG7$ 
check_foldersize=c:\windows\system32\cscript.exe //NoLogo //T:30 "C:\Program Files\NSClient++\scripts\check_folder_size.vbs" "$ARG1$" $ARG2$ $ARG3$ 
check_foldersize2=c:\windows\system32\cscript.exe //NoLogo //T:30 "C:\Program Files\NSClient++\scripts\check_folder_size.vbs" "$ARG1$" $ARG2$ $ARG3$ $ARG4$ $ARG5$ 
check_dfsutil=perl scripts\check_win_dfsutil.pl -H $ARG1$ $ARG2$ 
dfsutil_cmd=dfsutil $ARG1$ $ARG2$ 
check_dfsdiag=perl scripts\check_win_dfsdiag.pl -H $ARG1$ -A "$ARG2$" 
check_dfsrdiag=perl scripts\check_win_dfsrdiag_backlog.pl -H $ARG1$ -A "$ARG2$" -w $ARG3$ -c $ARG4$ 
check_file_mtime=perl scripts\check_file_mtime.pl -f "$ARG1$" -t "$ARG2$" "-$ARG3$" 
;Citrix WMI monitoring plugins 
check_licenses_pl=perl scripts\check_licenseserver.pl -w $ARG1$ -c $ARG2$ 
check_licenses_vbs=cscript.exe //nologo "C:\Program Files\NSClient++\scripts\check_ctx_lic.vbs" $ARG1$ $ARG2$ $ARG3$ $ARG4$ 
check_num_servers_in_zone=cscript.exe //nologo "C:\Program Files\NSClient++\scripts\check_num_servers_in_zone.vbs" $ARG1$ $ARG2$ 
check_active_session=cscript.exe //nologo "C:\Program Files\NSClient++\scripts\check_active_session.vbs" $ARG1$ $ARG2$ 
check_disconnected_session=cscript.exe //nologo "C:\Program Files\NSClient++\scripts\check_disconnected_session.vbs" $ARG1$ $ARG2$ 
check_metaframe_application_loadlevel=cscript.exe //nologo "C:\Program Files\NSClient++\scripts\check_metaframe_application_loadlevel.vbs" $ARG1$ $ARG2$ 
check_metaframe_server_loadlevel=cscript.exe //nologo "C:\Program Files\NSClient++\scripts\check_metaframe_server_loadlevel.vbs" $ARG1$ $ARG2$ 
check_backupexec=cscript.exe scripts\check_backupexec.vbs //Nologo 
check_be=scripts\check_be.exe "C:\Program Files\Symantec\Backup Exec\Data" "$ARG1$" -w"$ARG2$" -c"$ARG3$" 
[External Alias] 
alias_cpu=checkCPU warn=80 crit=90 time=5m time=1m time=30s 
alias_cpu_ex=checkCPU warn=$ARG1$ crit=$ARG2$ time=5m time=1m time=30s 
alias_mem=checkMem MaxWarn=80% MaxCrit=90% ShowAll=long type=physical type=virtual type=paged type=page 
alias_up=checkUpTime MinWarn=1d MinWarn=1h 
alias_disk=CheckDriveSize MinWarn=10% MinCrit=5% CheckAll FilterType=FIXED 
alias_disk_loose=CheckDriveSize MinWarn=10% MinCrit=5% CheckAll FilterType=FIXED ignore-unreadable 
alias_volumes=CheckDriveSize MinWarn=10% MinCrit=5% CheckAll=volumes FilterType=FIXED 
alias_volumes_loose=CheckDriveSize MinWarn=10% MinCrit=5% CheckAll=volumes FilterType=FIXED ignore-unreadable 
alias_service=checkServiceState CheckAll 
alias_service_ex=checkServiceState CheckAll "exclude=Net Driver HPZ12" "exclude=Pml Driver HPZ12" exclude=stisvc 
alias_process=checkProcState "$ARG1$=started" 
alias_process_stopped=checkProcState "$ARG1$=stopped" 
alias_process_count=checkProcState MaxWarnCount=$ARG2$ MaxCritCount=$ARG3$ "$ARG1$=started" 
alias_process_hung=checkProcState MaxWarnCount=1 MaxCritCount=1 "$ARG1$=hung" 
alias_event_log=CheckEventLog file=application file=system MaxWarn=1 MaxCrit=1 "filter=generated gt -2d AND severity NOT IN ('success', 'informational') AND source != 'SideBySide'" truncate=800 unique descriptions "syntax=%severity%: %source%: %message% (%count%)" 
alias_file_size=CheckFiles "filter=size > $ARG2$" "path=$ARG1$" MaxWarn=1 MaxCrit=1 "syntax=%filename% %size%" max-dir-depth=10 
alias_file_age=checkFile2 filter=out "file=$ARG1$" filter-written=>1d MaxWarn=1 MaxCrit=1 "syntax=%filename% %write%" 
alias_sched_all=CheckTaskSched "filter=exit_code ne 0" "syntax=%title%: %exit_code%" warn=>0 
alias_sched_long=CheckTaskSched "filter=status = 'running' AND most_recent_run_time < -$ARG1$" "syntax=%title% (%most_recent_run_time%)" warn=>0 
alias_sched_task=CheckTaskSched "filter=title eq '$ARG1$' AND exit_code ne 0" "syntax=%title% (%most_recent_run_time%)" warn=>0 
alias_updates=check_updates -warning 0 -critical 0 
check_ok=CheckOK Everything is fine! 
[Wrapped Scripts] 
;check_test_vbs=check_test.vbs /arg1:1 /arg2:1 /variable:1 
;check_test_ps1=check_test.ps1 arg1 arg2 
;check_test_bat=check_test.bat arg1 arg2 
;check_battery=check_battery.vbs 
;check_printer=check_printer.vbs 
;check_updates=check_updates.vbs 
; [includes] 
;# The order when used is "reversed" thus the last included file will be "first" 
;# Included files can include other files (be carefull only do basic recursive checking) 
; 
; myotherfile.ini 
; real.ini 
[NSCA Agent] 
;# CHECK INTERVALL (in seconds) 
; How often we should run the checks and submit the results. 
;interval=5 
; 
;# ENCRYPTION METHOD 
; This option determines the method by which the send_nsca client will encrypt the packets it sends 
; to the nsca daemon. The encryption method you choose will be a balance between security and 
; performance, as strong encryption methods consume more processor resources. 
; You should evaluate your security needs when choosing an encryption method. 
; 
; Note: The encryption method you specify here must match the decryption method the nsca daemon uses 
;  (as specified in the nsca.cfg file)!! 
; Values: 
; 0 = None (Do NOT use this option) 
; 1 = Simple XOR (No security, just obfuscation, but very fast) 
; 2 = DES 
; 3 = 3DES (Triple DES) 
; 4 = CAST-128 
; 6 = xTEA 
; 8 = BLOWFISH 
; 9 = TWOFISH 
; 11 = RC2 
; 14 = RIJNDAEL-128 (AES) 
; 20 = SERPENT 
;encryption_method=14 
; 
;# ENCRYPTION PASSWORD 
; This is the password/passphrase that should be used to encrypt the sent packets. 
;password= 
; 
;# BIND TO ADDRESS 
; Allows you to bind server to a specific local address. This has to be a dotted ip adress not a hostname. 
; Leaving this blank will bind to "one" local interface. 
; -- not supported as of now -- 
;bind_to_address= 
; 
;# LOCAL HOST NAME 
; The name of this host (if empty "computername" will be used. 
;hostname= 
; 
;# NAGIOS SERVER ADDRESS 
; The address to the nagios server to submit results to. 
;nsca_host=192.168.0.1 
; 
;# NAGIOS SERVER PORT 
; The port to the nagios server to submit results to. 
;nsca_port=5667 
; 
;# CHECK COMMAND LIST 
; The checks to run everytime we submit results back to nagios 
; Any command(alias/key) starting with a host_ is sent as HOST_COMMAND others are sent as SERVICE_COMMANDS 
; where the alias/key is used as service name. 
; 
[NSCA Commands] 
;my_cpu_check=checkCPU warn=80 crit=90 time=20m time=10s time=4 
;my_mem_check=checkMem MaxWarn=80% MaxCrit=90% ShowAll type=page 
;my_svc_check=checkServiceState CheckAll exclude=wampmysqld exclude=MpfService 
;host_check=check_ok 
;# REMOTE NRPE PROXY COMMANDS 
; A list of commands that check other hosts. 
; Used by the NRPECLient module 
[NRPE Client Handlers] 
check_other=-H 192.168.0.1 -p 5666 -c remote_command -a arguments 
;# LUA SCRIPT SECTION 
; A list of all Lua scripts to load. 
;[LUA Scripts] 
;scripts\test.lua 
[EventLog] 
debug=0 
buffer_size=512000 
[NRPE Handlers] 
exch_dag=cmd /c echo scripts\ExDAG.ps1; exit $LastExitCode; | powershell.exe -command – 
exch_mail_flow10=cmd /c echo scripts\ExchMailFlow10.ps1; exit $LastExitCode | powershell.exe -command - 
exch_mailboxhealth10=cmd /c echo scripts\ExMailboxhealth10.ps1; exit $LastExitCode | powershell.exe -command – 
exch_mapi10=cmd /c echo scripts\ExchMapi10.ps1; exit $LastExitCode | powershell.exe -command - 
exch_queue_health10=cmd /c echo scripts\ExQueueHealth10.ps1; exit $LastExitCode | powershell.exe -command - 
exch_search10=cmd /c echo scripts\ExchSearch10.ps1; exit $LastExitCode | powershell.exe -command - 
exch_service_alert10=cmd /c echo scripts\ExServiceAlert10.ps1; exit $LastExitCode | powershell.exe -command – 
;#Windows Update Checker 
check_updates=c:\windows\system32\cscript.exe //NoLogo //T:40 "C:\Program Files\NSClient++\scripts\check_updates.wsf" $ARG1$ 
check_foldersize=c:\windows\system32\cscript.exe //NoLogo //T:30 "C:\Program Files\NSClient++\scripts\check_folder_size.vbs" "$ARG1$" $ARG2$ $ARG3$ 
check_foldersize2=c:\windows\system32\cscript.exe //NoLogo //T:30 "C:\Program Files\NSClient++\scripts\check_folder_size.vbs" "$ARG1$" $ARG2$ $ARG3$ $ARG4$ $ARG5$ 
check_dfsutil=perl scripts\check_win_dfsutil.pl -H $ARG1$ $ARG2$ 
dfsutil_cmd=dfsutil $ARG1$ $ARG2$ 
dfsdiag_cmd=dfsdiag $ARG1$ $ARG2$ 
dfsrdiag_cmd=dfsrdiag $ARG1$ $ARG2$ 
check_dfsdiag=perl scripts\check_win_dfsdiag.pl -H $ARG1$ -A "$ARG2$" 
check_dfsrdiag=perl scripts\check_win_dfsrdiag_backlog.pl -H $ARG1$ -A "$ARG2$" -w $ARG3$ -c $ARG4$ 
check_file_mtime=perl scripts\check_file_mtime.pl -f "$ARG1$" -t "$ARG2$" "-$ARG3$" 
;Citrix WMI monitoring plugins 
check_licenses_pl=perl scripts\check_licenseserver.pl -w $ARG1$ -c $ARG2$ 
check_licenses_vbs=cscript.exe //nologo "C:\Program Files\NSClient++\scripts\check_ctx_lic.vbs" $ARG1$ $ARG2$ $ARG3$ $ARG4$ 
check_num_servers_in_zone=cscript.exe //nologo "C:\Program Files\NSClient++\scripts\check_num_servers_in_zone.vbs" $ARG1$ $ARG2$ 
check_active_session=cscript.exe //nologo "C:\Program Files\NSClient++\scripts\check_active_session.vbs" $ARG1$ $ARG2$ 
check_disconnected_session=cscript.exe //nologo "C:\Program Files\NSClient++\scripts\check_disconnected_session.vbs" $ARG1$ $ARG2$ 
check_metaframe_application_loadlevel=cscript.exe //nologo "C:\Program Files\NSClient++\scripts\check_metaframe_application_loadlevel.vbs" $ARG1$ $ARG2$ 
check_metaframe_server_loadlevel=cscript.exe //nologo "C:\Program Files\NSClient++\scripts\check_metaframe_server_loadlevel.vbs" $ARG1$ $ARG2$ 
check_nbu_backup=cmd /c echo scripts\check_nbu_backstat.ps1 -nbuClient $ARG1$; exit $LastExitCode | powershell.exe -command - 
check_nbu_backup2=cscript.exe //nologo "C:\Program Files\NSClient++\scripts\check_nbu_backstat.vbs" /nbuClient:$ARG1$ /filePath:"$ARG2$" 
check_dcdiag=scripts\check_ad.exe --dc 
check_dcdiag2=perl scripts\check_ad.pl --dc 
check_dcdiag3=cscript.exe //nologo scripts\check_AD.vbs 

Пожалуйста, дайте мне знать, если требуется здесь какая-либо дополнительная информация. Заранее спасибо.

+0

Зачем все проблемы с echo-n-pipe сценарием Powershell? Вы можете просто передать имя scirpt в качестве аргумента, например: 'powershell -file c: \ myPath \ MyScript.ps1' – vonPryz

+0

Спасибо, фон! Он не работает в NSclient ++. Используя ваше предложение, я могу выполнить сценарий PS1 в обычной командной строке, но не изнутри агента Nsclient ++. NSClient ++ предлагает определенный способ выполнения сценария PS1. Иногда мы передаем несколько аргументов сценарию и возвращаем $ LastExitCode (значение возврата скрипта) в процесс удаленного вызова (check_nrpe). –

+0

В конце концов я могу взломать проблему, и ее было очень сложно найти. Наш администратор скопировал/вставил командную строку для файла NSC.ini из документа MS-Word (How to doc.), Предоставленного мне им. В исходном документе MS-Word hypen (в конце строки после команды word в приведенной командной строке) автоматически изменился на несколько более высокий уровень во время документации, который также попал в файл NSC.ini и, следовательно, ошибка для этого выполнения конкретной команды. После изменения hypen вручную в NSC.ini, он отлично работал без каких-либо проблем. –

ответ

0

В конце концов я могу взломать проблему, и ее было очень сложно найти. Наш администратор скопировал/вставил командную строку для файла NSC.ini из документа MS-Word (How to doc.), Предоставленного мне им. В исходном документе MS-Word hypen (в конце строки после команды word в приведенной командной строке) автоматически изменился на несколько более высокий уровень во время документации, который также попал в файл NSC.ini и, следовательно, ошибка при выполнении этой конкретной команды. После изменения гипна вручную в NSC.ini, он работал нормально без каких-либо проблем