Quest Defender Token License exceeds a defined percentage

Posted: August 22, 2013 in Powershell
Tags: , , , , , ,

This script is was written to help you keep an eye on you Quest Defender Tokens ( Now Dell ).

 

 

 

#**********************************************************************************
# Created with: SAPIEN Technologies, Inc., PowerShell Studio 2012 v3.0.7
# Created on: 8/22/2013 9:08 AM
# Created by: Darin Torr darintorr@hotmail.com
# Organization: Epsilon
# Filename:Defender_Token_Pecentage.ps1
# Special thanks to : Aidan McCarthy for helping with the percentage setup
#
# Info: PowerShell script to send an email if any Defender License exceeds a defined percentage.
#
#
#
#**********************************************************************************
#
# THIS CODE AND INFORMATION ARE PROVIDED “AS IS” WITHOUT WARRANTY OF ANY
# KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
# PARTICULAR PURPOSE.
#
# **********************************************************************************

# PowerShell script to send an email if any Defender License exceeds a defined percentage.

$ErrorActionPreference = “silentlycontinue”

#Get Defender license information
Add-PSSnapin Quest.Defender.AdminTools

$store = Get-DefenderLicense

#extract each row and calculate percentage of license used.
#foreach ($var in $store)
#{
$percent = 0
$licensetype = $store.LicenseType
$userassigned = $store.AssignedUsers
$usertotal = $store.TotalUsers
$tokensfree = ($usertotal-$userassigned)
$percent = $percent + ($userassigned/$usertotal)*100

#determine percentage value of license usage to trigger email (change ’90’ value to percentage you wish to use).
If ($percent -ge 80) { $sendemail++ }

$percent = “{0:N2}” -f ($percent)
#the below message can be edited if required. To do so edit the text between the double quotes.
$body += ,”
$percent percent of license used.
$tokensfree tokens left for distribution.

$licensetype License has $userassigned users assigned.
The total of the license is $usertotal.”
#}

$body

#Send email if any license hits the value specified. Change -From, -To & -SmtpServer settings appropriately to match your environment.
if ($sendemail -ge 1) {
Send-MailMessage -From “Quest Defender <yourserver@yourdomain.com>” -To “youremail@email.com” -Subject “Quest Defender – Daily Token Summary” -Body “$body” -SmtpServer “smtp.server”}

 

## End Script

 

Here is what the email looks like

 

85.81 percent of license used.

1111 tokens left for distribution.

 

Permanent License has 6716 users assigned.

The total of the license is 7827.

 

 

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s