Posts Tagged ‘defender license’

So I finally got feed up with getting burned by running out of token license’s without having a heads up …..  Quest’s  Defender Report Console (Version 5.6.0.2182) doesn’t have the ability to schedule reports and email them. After searching the web forever and not finding anything I decided to write a powershell script to connect to the quest defender reporting url and parse out the token license info.

Feel free to use and modify.  Enjoy and I hope I saved you some time 🙂

*** Copy Below Here***

#—————————————————————————-
# Author: Darin Torr
#
#
# This script connects to Quest Defender Reporting Console then parses the xml
# to extract token license counts and emails results
#
# Current Version: v1.1
# Version History
#
#
# 5/06/2012 – v1 – Initial Revision.
# 5/06/2012 -v1.1 – Added html and xml file cleanup on report server
#—————————————————————————-

# // Uncomment this to create secure password
#$secureString = Read-Host -AsSecureString
#ConvertFrom-SecureString $secureString | out-file c:\encrypted.txt
#$secure = gc C:\encrypted.txt | ConvertTo-SecureString

# // This is to clean up any old xml and html files from running reports
$reporthtml = “C:\Program Files (x86)\Quest Software\Defender\Defender Report Console\downloads\html\*.html”
$reportxml = “C:\Program Files (x86)\Quest Software\Defender\Defender Report Console\downloads\*.xml”
if (Test-Path $reporthtml)
{
Remove-item $reporthtml
}
if (Test-Path $reportxml)
{
Remove-item $reportxml
}

# // Change to reflect your servername
$url = “http://server/cgi-bin/d5dsslicensereport.exe?mode=0&xsl=d5licensereport.xsl”
# // create a request
[Net.HttpWebRequest] $req = [Net.WebRequest]::create($url)
$req.Method = “GET”
$req.Timeout = 600000 # = 10 minutes

# // Set if you need a username/password to access the resource
$secure = gc C:\encrypted.txt | ConvertTo-SecureString;
$UserName = “domain\username”;
$req.Credentials = New-Object System.Management.Automation.PSCredential($UserName, $secure);

# // Reading data from page
[Net.HttpWebResponse] $result = $req.GetResponse()
[IO.Stream] $stream = $result.GetResponseStream()
[IO.StreamReader] $reader = New-Object IO.StreamReader($stream)
[string] $output = $reader.readToEnd()
$stream.flush()
$stream.close()
$output | out-null
[xml]$defxml = $output
$final = $defxml.defender_license.desktop_license | select Type,Assigned,Allocation | ConvertTo-Html
function SendMail
{
#Mail Variables
$EmailFrom = “who@ever.com>”
$EmailSubject = “Daily Defender Token Count”
$smtpServer = “relay”
$SendTo = “you@yours.com”
$date = (Get-Date -format “MM-dd-yyyy”)

$mailmessage = New-Object system.net.mail.mailmessage

############## MAIL BODY #############

# Update body with any text you want and variables # #
######################################

$body = “
<lang=EN-US link=blue vlink=purple><div><p>
<span style=font-size:10.0pt;font-family:tahoma,sans-serif;color:#595959>
<dd><p><b>Defender Token count as of $date </b>
<p>
<p><pre style=font-size:10.0pt;font-family:tahoma,sans-serif;color:black> $final <b style=color:red></b></pre>
<p>
</dd></span></b></p>”
#Mail info
$mailmessage.from = $emailfrom
$mailmessage.To.add($sendto)
$mailmessage.Subject = $emailsubject
$mailmessage.Body = $body
$mailmessage.IsBodyHTML = $true
$SMTPClient = New-Object Net.Mail.SmtpClient($SmtpServer, 25)
$SMTPClient.Send($mailmessage)

}
SendMail

***End Copy Just Above This***

Here is what your output will look like

Defender Token count as of 06-06-2012 

type assigned allocation
Windows Desktop Token 14075 15000
Palm Desktop Token 0 25
Blackberry Desktop Token 179 7000
Windows Mobile/iPAQ Desktop Token 0 25
SMS Token 0 25
GrIDsure Soft Token 6000 10525
Android Desktop Token 2180 7000
E-mail OTP Desktop Token 0 25