I would like to pass two arguments to my function and set a variable (and variable name) based on the results. I've been trying to do this the following way:
$service_to_check_for = "ping"
function check-service-monitored ($check_command,$check_name) {
if($service_to_check_for -eq $check_command)
{
$Value = "Yes"
}
else
{
$Value = "No"
}
$script:check_command = $check_command
$script:check_name = $check_name
$script:value = $Value
}
check-service-monitored "ping" "NagiosPing"
echo "$check_name : $value"
I would like
$NagiosPing = "Yes"
but how?