KS-Soft. Network Management Solutions
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister    ProfileProfile    Log inLog in 

Simple reminder test

 
Post new topic   Reply to topic    KS-Soft Forum Index -> Configuration, Maintenance, Troubleshooting
View previous topic :: View next topic  
Author Message
Bobzbobz



Joined: 30 Nov 2010
Posts: 30
Location: Denmark

PostPosted: Tue Jun 02, 2020 5:34 am    Post subject: Simple reminder test Reply with quote

Hello

Is it possible to create a simple "reminder test" based on a specific date, which then alerts when X days until a date is reached.

I am using a license server to apply educational licenses to our Autodesk-products. These licenses only last 1 year and then need renewal. The licenses are specified in a .txt-file.

I would like to create a test where I can specify the renewal-date and then have it come out with "bad status" when there are 30 days left.
Back to top
View user's profile Send private message
KS-Soft



Joined: 03 Apr 2002
Posts: 12792
Location: USA

PostPosted: Tue Jun 02, 2020 6:18 am    Post subject: Reply with quote

I see several options

1) If your system date format looks like YYYY-MM-DD, you may set any test with static good result (e.g. Ping localhost) with the following option
- Use Warning status if "%Date%">"2021-05-01"

2) You may use Schell Script test method and create simple script that will check system date (e.g. VBScript, JavaScript or PowerShell)

3) Create any file, set modification timestamp to May 02, 2021, set File/Folder Availablity test using the following option
- Alert when file does not exist or older then 1 min

Option #2 is the most reliable, it will work if system date format changes, it will not fail if someone opens file in text editor and clicks File->Save

Regards
Alex
Back to top
View user's profile Send private message Visit poster's website
Bobzbobz



Joined: 30 Nov 2010
Posts: 30
Location: Denmark

PostPosted: Thu Jun 04, 2020 1:03 am    Post subject: Reply with quote

Thank you for the quick reply

Should this work?
I get "Error: Invalid Result"

Code:
$statusAlive       = "ScriptRes:Host is alive:"
$statusDead        = "ScriptRes:No answer:"
$statusUnknown     = "ScriptRes:Unknown:"
$statusNotResolved = "ScriptRes:Unknown host:"
$statusOk          = "ScriptRes:Ok:"
$statusBad         = "ScriptRes:Bad:"
$statusBadContents = "ScriptRes:Bad contents:"

$CurDate = Get-Date -Format "dd-MM-yyyy"

if ($args[0]>$CurDate)
{
  echo  $statusBad"$CurDate"
  exit
}
else
{
  echo  $statusOk
  exit
}
Back to top
View user's profile Send private message
KS-Soft



Joined: 03 Apr 2002
Posts: 12792
Location: USA

PostPosted: Thu Jun 04, 2020 7:08 am    Post subject: Reply with quote

Get-Date -Format "dd-MM-yyyy" returns a string, not a date.
(Get-Date returns date)
So if you want to compare strings then use different format
Get-Date -Format "yyyy-MM-dd"

Also, check list of comparison operators
https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_comparison_operators?view=powershell-7

Code:

$statusUnknown     = "ScriptRes:Unknown:"
$statusOk          = "ScriptRes:Ok:"
$statusBad         = "ScriptRes:Bad:"

if (!$args[0]) {
  echo  $statusUnknown"Date (YYYY-MM-DD) parameter is not specified"
  exit
}

$CurDate = Get-Date -Format "yyyy-MM-dd"
if ($args[0] -gt $CurDate)
{
  echo  $statusBad"$CurDate"
}
else
{
  echo  $statusOk
}


Regards
Alex
Back to top
View user's profile Send private message Visit poster's website
Bobzbobz



Joined: 30 Nov 2010
Posts: 30
Location: Denmark

PostPosted: Mon Jun 08, 2020 6:15 am    Post subject: Reply with quote

Thank you.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    KS-Soft Forum Index -> Configuration, Maintenance, Troubleshooting All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group

KS-Soft Forum Index