Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Prepare for PDF export

Anchor
TOC
TOC
Include Page
KBCOMMON:KB-CSSstyle
KBCOMMON:KB-CSSstyle
Version: 1.18 - Published 

...

The goal of this Powershell script is to read the license content and send alerts 15 days (by default) before expiration. This document is related to the kit versions 1.9 to 1.17.

...

This utility is replaced by CHARON on Windows - Charon License Utility that provides a graphical interface providing the Windows server has PowerShell 5.1 and .NET Framework 4.6 minimum installed (4.8 recommended) installed.

Alerts consist in:

  • Adding a Windows Event entry in the Application log
  • Executing a customized script named "expiredlicense.bat" that can execute actions at your convenience: send an email, send an event to a monitoring software, etc...

...

  • Open a command line window
  • Move to the folder you created, example: C:\Charon
  • Execute the powershell script. The following parameters can be passed to the script:
    • "-folder" is used to specify where the scripts (.ps1 and .bat) are stored. If not specified, default is "C:\Charon"
    • "-nbdays" is used to specify the number of days before expiration to start sending alerts, default is 15
    • "-nbhours" is used to specify the number of hours before expiration of a backup/spare license (time limited) to start sending alerts, default is 96. Must not be lower than 72.
    • "-usevanilla" is used in case the hasp_view.exe program is not able to provide the expiration date in the output file (bug found in builds 18304 and 18305 with hasp_view.exe version 1.26). In this case, the script will use the hasp_view.exe program located in the "xxxxx_ORIGINALS_xxx_PATCH_xxx" folder (example: B18302_ORIGINALS_AXP_PATCH_X64). The bug is solved with hasp_view.exe version 1.27 and later.
    • "-haspview <hasp_view.exe location>" is used to specify the location of the hasp_view.exe file. If this parameter is not specified then the script searches for the location itself depending on Charon installation folder. It is used in case a license server performs the checks instead of the server hosting the Charon virtual machines. The "-usevanilla" parameter is ignored if this parameter is defined.
    • "-ini <file>" is used to specify a file where the -folder, -nbdays, -nbhours-usevanilla, -haspview and -tick parameters can be stored. Priority goes to the parameters passed in the command line then those in the specified file. The file is used to facilitate updates in the parameters passed in the tasks scheduler (update the file instead of the task).
    • "-tick" parameter is used to execute external script (expiredlicense.bat) even if no alert is detected (counter alert for monitoring software). If used in the .ini file, "1", "y", "yes" or "true" value activates it, other values will invalidate (Example: tick=true)

...


To run PowerShell scripts (files that end with .ps1), you must first set the execution policy to Unrestricted (This operation has to be done once).

To do so, open a command line window (cmd.exe) as an Administrator and use the following command:
c:\Charon>powershell -command "Set-ExecutionPolicy Unrestricted"

(info) The ExecutionPolicy can also be set to "RemoteSigned". In this case the .ps1 script files will have to be unblocked as described below.

If you are still prompted to allow for execution of the script, please run the following command to unblock the downloaded charon_expchk.ps1 file:
c:\Charon>powershell -command "Unblock-File -path c:\charon\charon_expchk.ps1"

Example:

c:\Charon>powershell -file charon_expchk.ps1 -folder c:\charon -nbdays 20

...


Div
classsmall

c:\Charon>schtasks /create /SC DAILY /ST 09:00 /NP /RL HIGHEST /TN "CHARON\CHARON License Expiration Check" ^
More?
/TR "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -file c:\Charon\charon_expchk.ps1 -folder c:\Charon"


...


Div
classsmall

c:\Charon>schtasks /create /SC DAILY /ST 09:00 /NP /RL HIGHEST /TN "CHARON\CHARON License Expiration Check" ^
More? /
TR "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -file c:\Charon\charon_expchk.ps1 -ini c:\Charon\charon_expchk.ini"


...