Mar 162015
 

UPDATE:  I found trying to run this script through the Netscaler Gateway failed due to differences in the web pages.  I re-wrote the script so it will work internal directly to StoreFront, and externally with Netscaler Gateway.  The main caveat is that the wficalib.dll doesn’t allow you to logoff the session when going through the gateway.  I simply set it to look for any wfica32 processes prior to launching the application/desktop, compare that to the processes after launch, and kill the new process (disconnecting the session).  The script identifies the webpage as a gateway if */vpn/* is in the path.  I also set it to logoff of the Storefront/Gateway page when it ends the script.  If you were to run it back to back without logging off of the page it wouldn’t find what it is looking for initially and fail (because you’d probably already be logged on).  I may re-write this in the future with more functions to make it a bit shorter/cleaner, but as is it should work.
NOTE: I tested this with Netscaler 10.5… it may not work with previous versions as is, but if you read the script you should be able to figure out what needs to be changed.

I need to give credit to this Citrix blog post for getting me started.  This script will launch an application or desktop as a user you specify from the StoreFront web page, then send you an email to let you know if it was successful or not.

Variables you should edit:

In the send-results function
$smtpserver (line 19)
$msg.From (line 28)
$msg.to.Add (line 29)

In the main script (be sure to read the comments)
$username (line 84)
$passstring (line 86)
$resource (line 92)
$mask (line 94)
$wait (line 96)
$internetexplorer.visible (line 98)
$internetexplorer.navigate2 (line 99)

Requirements:
Powershell (x86)! – otherwise you cannot tie into the x86 dll for Receiver
(If you are going to the Netscaler Gateway it doesn’t matter which version as we won’t tie into the dll in that case)

Add the following to the registry if you are pointing to the internal StoreFront url – if you are pointing to the Netscaler Gateway it won’t matter
Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Citrix\ICA Client\CCM]
“AllowLiveMonitoring”=dword:00000001
“AllowSimulationAPI”=dword:00000001

If you are running on an x86 machine change the registry path to exclude Wow6432Node, and change the path of the .dll on line 156 of the script to the correct path of the wficalib.dll.

Here is the script!

Contact me in in the channel David62277

  2 Responses to “StoreFront App/Desktop Launch Testing Script”

  1. […] Ott StoreFront App/Desktop Launch Testing Script uses Internet Explorer to login to StoreFront and launch a resource. Sends email with the result. […]

  2. Gives me tons of error-

    At C:\Temp\SFLauncher.ps1:99 char:48
    + $Buttons = @([System.__ComObject].InvokeMember(“getElementsByTagNam …
    + ~
    Missing ‘)’ in method call.
    At C:\Temp\SFLauncher.ps1:99 char:48
    + … ([System.__ComObject].InvokeMember(“getElementsByTagName”,[System …
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~
    Unexpected token ‘“getElementsByTagName”’ in expression or statement.
    At C:\Temp\SFLauncher.ps1:99 char:74
    + … [System.__ComObject].InvokeMember(“getElementsByTagName”,[System. …
    + ~
    Missing argument in parameter list.
    At C:\Temp\SFLauncher.ps1:98 char:26
    + if ($gateway -eq $false) {
    + ~
    Missing closing ‘}’ in statement block or type definition.
    At C:\Temp\SFLauncher.ps1:96 char:51
    + while ((check-buttons -buttons $buttons) -eq “0”) {
    + ~
    Missing closing ‘}’ in statement block or type definition.
    At C:\Temp\SFLauncher.ps1:1 char:21
    + function end-script {
    + ~
    Missing closing ‘}’ in statement block or type definition.
    At C:\Temp\SFLauncher.ps1:99 char:145
    + … ystem.Reflection.BindingFlags]::InvokeMethod, $null, $document, “a”))
    + ~
    Unexpected token ‘)’ in expression or statement.
    At C:\Temp\SFLauncher.ps1:100 char:1
    + } else {
    + ~
    Unexpected token ‘}’ in expression or statement.
    At C:\Temp\SFLauncher.ps1:101 char:48
    + $Buttons = @([System.__ComObject].InvokeMember(“getElementsByTagNam …
    + ~
    Missing ‘)’ in method call.
    At C:\Temp\SFLauncher.ps1:101 char:48
    + … ([System.__ComObject].InvokeMember(“getElementsByTagName”,[System …
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~
    Unexpected token ‘“getElementsByTagName”’ in expression or statement.
    Not all parse errors were reported. Correct the reported errors and try again.
    + CategoryInfo : ParserError: (:) [], ParseException
    + FullyQualifiedErrorId : MissingEndParenthesisInMethodCall

Leave a Reply to Deep Cancel reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">

(required)

(required)

This site uses Akismet to reduce spam. Learn how your comment data is processed.