trying to use a script to test a backup to see if it works but im getting a false-positive (everything passes).
If i change one of the services to be something that doesn't exist (such as service name being "FakeNews") or to a process that should be off - it still gets a success.
I altered a script i saw on the veeam website. The scripts seems to work when ran manually on the server but provide a false positive once ran by veeam.
Any clue?
In sure backup i have Path as:
C:\veeam\test.bat
Arguments: (actual server name and services changed)
"Server01" "service1" "service2" "service3"
Batch script:
Code: Select all
REM
@ECHO OFF
SETLOCAL EnableExtensions EnableDelayedExpansion
powershell.exe -noninteractive -noprofile -command "& {C:check.ps1 \"%1\" \"%2\" \"%3\" \"%4\" }"
EXIT /B %errorlevel%
Powershell:
Code: Select all
param(
[string] $ip, #passed as a DNS name, application group has a DC+DNS launch before this server comes up
[string] $service_one,
[string] $service_two,
[string] $service_three )
#Service name
$result_one = (get-Service -ComputerName $ip -Name $service_one -ErrorAction SilentlyContinue)
$result_two = (get-Service -ComputerName $ip -Name $service_two -ErrorAction SilentlyContinue)
$result_three = (get-Service -ComputerName $ip -Name $service_three -ErrorAction SilentlyContinue)
if($result_one.status -eq "Running")
{
if($result_two.status -eq "Running")
{
if($result_three.status -eq "Running")
{
exit
}
else
{
write-host ("Error 3, Service '" + $service + "' not running or not found.")
$host.SetShouldExit(1)
exit
}
}
else
{
write-host ("Error 2, Service '" + $service + "' not running or not found.")
$host.SetShouldExit(1)
exit
}
}
else
{
write-host ("Error 1, Service '" + $service + "' not running or not found.")
$host.SetShouldExit(1)
exit
}