Clarity Service Management

pdm_webstat PowerShell script for AA architecture 

06-17-2016 02:08 PM

pdm_webstat usage example in AA environment

The following is a simple PowerShell script I wrote which will write the pdm_webstat output from all servers in your environment into a single text file and optionally send it as an attachment via email.



  • I've only used this in a domain environment where I have admin privileges on all the service desk servers.
  • The Send-MailMessage command is structured assuming there is an unsecured SMTP server available
  • icm is an alias for Invoke-Command PowerShell command
  • cn is short for the computer name flag
  • $app_srvrs is an array containing the fully qualified domain names for all app servers in the environment
  • Each entry in the $app_srvrs array is set to the $srvr variable as it's run in the ForEach loop


Using the script:

  • Set each appx_fqdn entry to the appropriate server FQDNs in your environment, you can add/remove additional servers onto the array
  • Set the <output_location> to a location on the background server or an open share in the environment
  • webstat_$(get-date -f yyyy-MM-dd-hhtt).txt is the filename used to concatenate the pdm_webstat results, the $(get-date -f yyyy-MM-dd-hhtt) variable appends the time stamp onto the filename
  • To enable the send-mailmessage command remove the comment blocks and set an appropriate SMTP server for your environment and update the recipients/from addresses


PowerShell script (also attached to document):

$app_srvrs = @("app1_fqdn","app2_fqdn","app3_fqdn","app4_fqdn","app5_fqdn")
 #Start all jobs
ForEach($srvr in $app_srvrs)
  $srvr | out-file "<output_location>\webstat_$(get-date -f yyyy-MM-dd-hhtt).txt" -append
    icm -cn $srvr -ScriptBlock { pdm_webstat } | out-file "<output_location>\webstat_$(get-date -f yyyy-MM-dd-hhtt).txt" -append
Send-MailMessage -Subject "Service Desk Manager Web Statistics" -To, -From -Body "Service Desk Manager web statistics report attached to email. Files saved to <a href=file:///<output_location>\webstats/>here</a>" -BodyAsHtml -SmtpServer <smtp_server> -Attachments "<output_location>\webstat_$(get-date -f yyyy-MM-dd-hhtt).txt"


Creating a scheduled task to execute the script:

The following shows how to create a repeating task that is executed every hour.  You can adjust this to your needs.

  • Task Trigger

  • Task Action and Argument

  • Argument: -ExecutionPolicy Bypass D:\scripts\Webstat_Email_Task.ps1

0 Favorited
1 Files
zip file   550B   1 version
Uploaded - 05-29-2019

Tags and Keywords


06-20-2016 10:29 AM

You're welcome!  I'm glad you find it useful.

06-20-2016 10:06 AM

Grant, thanks for the exclusive document. It helped us a lot....ArunavaS

Related Entries and Links

No Related Resource entered.