A
A
Albert Krozhezhepitskay2020-04-27 06:52:58
PowerShell
Albert Krozhezhepitskay, 2020-04-27 06:52:58

How to track the execution of PS scripts in zabbix?

Good afternoon.
Tell me how to track the execution of a PowerShell script in zabbix. Did it work or end with an error.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vladimir Korotenko, 2020-04-27
@firedragon

https://www.zabbix.com/documentation/2.4/manual/co...

$dest ="C: est"
New-Item $dest -type directory -force
$source ="c:samplefile.txt"
Copy-Item $source $dest
exit $LASTEXITCODE // или возвращайте свой код ошибки

M
MaxKozlov, 2020-04-27
@MaxKozlov

$LastExitCode
Contains the exit code of the last Windows-based program that was run.

So this is not
the same, but the idea is about the same as that of Vladimir Korotenko - exit $someHandMadeCode
for example, you can wrap the script try {} catch {} and return the error code from catch
try {
  Copy-Item -ErorAction Stop .......
}
catch {
  exit 1
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question