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 

...


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"


...

info
Code Block
languagepowershell
Param(
  [string]$lvl = "Information",
  [string]$msg = "no message"
)

$Hostname = (Get-Item env:\COMPUTERNAME).value
$Creds = Import-clixml C:\Charon\creds.clixml

#--- Customize the values below: "From" and "To" -----------------------------
$From = "<monitoring-account>@<somewhere>"
$To = "<someone>@<somewhere>"
#-----------------------------------------------------------------------------

send-mailmessage -to $To -from $From -subject "CHARON License Expiration Check for $Hostname ($lvl)" -body "$msg" -credential $Creds -smtpserver smtp.office365.com -usessl -port 587 -delivery none


(lightbulb) If you have to specify multiple recipients, an array has to be used as described below.

Example1:

$To = @( "James T. Kirk <kirk@uss-enterprise.fed>", "Spock <spock@uss-enterprise.fed>" )

Example2:

$To = @( "kirk@uss-enterprise.fed", "spock@uss-enterprise.fed", "uhura@uss-enterprise.fed" )


(info) The example shown above and another one given with embedded html code and colored email body are part of the kit downloaded previously.

...


Office365 email account is given here as an example but you can use "gmail" also and create a free dedicated account to send alerts. In this case the last line of the script(s) above has to be updated: the "-smtpserver" parameter has its "smtp.office365.com" value to be replaced by "smtp.gmail.com" (no other value to update)

(warning) Google may block sign-in attempts when using powershell and send-mailmessage. In this case the sender will receive a "Sign in attempt prevented" alert email. To allow emails to be sent:

  1. Create a dedicated gmail account
  2. Allow less secure apps to access your account. See this article: https://support.google.com/accounts/answer/6010255?hl=en


Include Page
KBCOMMON:KB-GoToTop
KBCOMMON:KB-GoToTop

...