Jump to content
Software FX Community

DrillDown Part 3. Invoking other apps or URLs


JuanC

Recommended Posts

Even if you are monitoring data that does not lend itself to drill down, you can use drilldown_script to invoke other applications or launching a browser to a specific URL. To show how to invoke other applications, let's write a script that collects information from multiple servers. We can use get-wmiobject to get information about the available space in the main hard drive of our servers as follows

ServersDisk.ps1
$servers = "machine1.yourdomain.com", "machine2.yourdomain.com", "machine3.yourdomain.com"
get-wmiobject -class Win32_LogicalDisk -computer $servers -credential yourdomain\Administrator -filter "DeviceID='C:'" | select __Server,FreeSpace

A couple of notes about our script

  • I am not running as a user that has administrative privileges in the server, so we have to use -credential
  • We are using a feature in get-wmiobject that allows you to query information from more than 1 computer. The name of the computer returned by this cmdlet in __SERVER does not contain domain information

Note that drilldown_script will simply invoke the specified string so you can supply a script name or the command you want to run, invoking the remote desktop client is very easy because the Remote Desktop app is located in the System32 folder so we just need its name.

PS C:\Temp> ServersDisk | out-chart -drilldown_script mstsc -drilldown_parameter {"/v:"+$_.__SERVER}

Now double click one of the bars, if you use the "Save Credentials" feature in the new remote desktop client you will get straight to the server in question.


To show how to launch a URL we will create a chart with the CPU utilization of all the virtual machines running on a virtual server, double clicking on a bar will now open the VM in question using the browser based VRM client.

VMCpu.ps1
get-wmiobject -class virtualmachine -namespace 'root/vm/virtualserver' -computername virtualserver.yourdomain.com | select Name,CPUUtilization

Note that Internet Explorer is not normally in a folder in your PATH so we have to specify the full path

PS C:\Temp> vmcpu | out-chart -drilldown_script 'C:\"Program Files"\"Internet Explorer"\iexplore' -drilldown_param {"http://virtualserver.yourdomain.com:1024/VirtualServer/VSWebApp.exe?view=3&vm="+$_.Name}

 This is a little more verbose but once you get it running, you can save it in a script for future use.

Acknowledgement
The URL portion of this post was inspired by Ben Pearce.

Link to comment
Share on other sites

×
×
  • Create New...