Random Project

Two problems fixed

Excellent script. During attemps to get it up and running, I encountered two problems.
1. There is a bug at line 56 – missing opening bracket.
Good:
if((Get-Date $now) -gt (Get-Date $last))
Wrong:
if(Get-Date $now) -gt (Get-Date $last))

Second, I have Windows 2012 server as my Veeam box. Locales are Czech. From some unknown reason, all functions like Get-Date return date in English format (even more confusing, when you try the same from command line, the locales _are_ taken into account). However, the GetScheduleOptions call returns date with proper locale, so after this attempt to convert it to date results in format error. Even I don“t understand exact nature of this problem, I found fix (this is for Czech format date):
The section of the code looks like this:

$last = $last -replace ‘], Next run time: .*’, ”

$fmt=”d. M. yyyy H:mm:ss”
$last = [datetime]::ParseExact($last,$fmt, $null)

if((Get-Date $now) -gt (Get-Date $last))

Hope this will somebody save some time.