modified: HP_printer_555/hp_smart_tank_plus_555_head_clean.ps1

This commit is contained in:
Tomasz Kostrzewa 2023-12-28 16:43:28 +01:00
parent 99a9730208
commit 97471031e8

View File

@ -62,6 +62,7 @@ $actual_time = get-date
# check if hour of running isnt restricted by $running_time_start and $running_time_stop # check if hour of running isnt restricted by $running_time_start and $running_time_stop
if (($actual_time.hour -lt $running_time_start) -and ($actual_time.hour -gt $running_time_stop)) { if (($actual_time.hour -lt $running_time_start) -and ($actual_time.hour -gt $running_time_stop)) {
$logs += log -l_level 0 -l_message "Hours between $running_time_start and $running_time_stop are restricted. EXIT" $logs += log -l_level 0 -l_message "Hours between $running_time_start and $running_time_stop are restricted. EXIT"
$logs += log -l_level 0 -l_message "Script Stopped"
log_store log_store
exit exit
} }
@ -88,6 +89,7 @@ try {
$actual_p_count = (snmpget -v $snmp_ver -c $snmp_community $printer_ip $snmp_code).Split(" ")[-1] $actual_p_count = (snmpget -v $snmp_ver -c $snmp_community $printer_ip $snmp_code).Split(" ")[-1]
} catch { } catch {
$logs += log -l_level 2 -l_message "Getting printed page count got ERROR. EXIT" $logs += log -l_level 2 -l_message "Getting printed page count got ERROR. EXIT"
$logs += log -l_level 0 -l_message "Script Stopped"
log_store log_store
exit exit
} }
@ -97,6 +99,7 @@ if ($actual_p_count -gt $last_run.p_count) {
$last_run.p_count = $actual_p_count $last_run.p_count = $actual_p_count
$last_run.date = $actual_time $last_run.date = $actual_time
$last_run | Export-Csv -Path $path_last_run -NoTypeInformation $last_run | Export-Csv -Path $path_last_run -NoTypeInformation
$logs += log -l_level 0 -l_message "Script Stopped"
log_store log_store
exit exit
} }
@ -114,6 +117,7 @@ if ($difference -gt $days_between) {
$last_run.date = $actual_time $last_run.date = $actual_time
} catch { } catch {
$logs += log -l_level 2 -l_message "Error durring connecting to printer." $logs += log -l_level 2 -l_message "Error durring connecting to printer."
$logs += log -l_level 0 -l_message "Script Stopped"
log_store log_store
exit exit
} }
@ -128,5 +132,6 @@ $last_run.p_count = $actual_p_count
$last_run | Export-Csv -Path $path_last_run -NoTypeInformation $last_run | Export-Csv -Path $path_last_run -NoTypeInformation
$logs += log -l_level 0 -l_message "Head Cleaning Stopped. Actual date: $actual_time. Actuall printed page count: $actual_p_count." $logs += log -l_level 0 -l_message "Head Cleaning Stopped. Actual date: $actual_time. Actuall printed page count: $actual_p_count."
$logs += log -l_level 0 -l_message "Script Stopped"
log_store log_store
exit exit