Showing posts with label xenapp. Show all posts
Showing posts with label xenapp. Show all posts

Friday, August 7, 2015

XenApp 6.5 published Windows Explorer using powershell

based on http://support.citrix.com/article/CTX131423

Using a Batch launcher for flexibility to run a powershell script instead of autoit.

[ExplorerLauncher.cmd]
@echo off
%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -executionPolicy bypass -file "C:\Program Files\AppScripts\ExplorerLauncher.ps1"
exit

[explorerlauncher.ps1]

#$Process = [Diagnostics.Process]::Start("notepad")
$process = Start-Process notepad -WindowStyle Minimized -PassThru
$id = $Process.Id
Write-Host "Pre-Launch Process created. Process id is $id"
Write-Host "sleeping for 2 seconds"
Start-Sleep -Seconds 2
Write-Host "Loading explorer"
Start-Process "Explorer" -ArgumentList "Z:\"
Write-Host "sleeping for 2 seconds"
try {
Stop-Process -Id $id -ErrorAction stop
Write-Host "Successfully killed the process with ID: $ID"
} catch {
Write-Host "Failed to kill the process"
}
Start-Sleep -Seconds 2
Write-host "Exiting Launch completed"
exit

Wednesday, September 3, 2014

Storefront Web Receiver White theme

Storefront Web Receiver White theme

1. Create my_backgroud.jpg plane white or with colored top, 2035x1534 put in contrib folder
1a. Create my_logo.png (209x35) and put in contrib
2. Dump this css into custom.style.css http://pastebin.com/mSU8jwuH
3. Fix any issue based round your environment, I suggest chrome

Citrix Netscaler Access Gateway Mobile Friendly White Theme

Hi,

If it helps anyone attached is some of my code to make the logon page white and mobile friendlier.
Assume you have 
1. Set Theme to Green bubble
2. Followed the ctx to create the custom theme

then in theory here is minimal touch to existing base code of the index.htm

3. Update index.html in /var/ns_gui_custom/ns_gui/vpn
<HEAD><TITLE>Citrix Access Gateway</TITLE>
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<META content=noindex,nofollow,noarchive name=robots>
<meta http-equiv="X-UA-Compatible" content="IE=IE9">
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="SHORTCUT ICON" href="/vpn/images/AccessGateway.ico" type="image/vnd.microsoft.icon">
<link href="/vpn/css/ctxs.mainstyle.css" rel="stylesheet" type="text/css" media="screen" />
<link href="/vpn/css/ctxs.authentication.css" rel="stylesheet" type="text/css" />
<link href="/vpn/custom/custom.css" rel="stylesheet" type="text/css">

http-equiv – fixes the IE10/11 compatibility viewing issue.

Viewport – supposed to make the  mobile play nice, good for sharefile logins.

4. Create folder ‘custom’ in /var/ns_gui_custom/ns_gui/vpn
Update the custom.css with your logo_company size/dimensions.
Copy in the custom.css
cipy in your Logo_company.png

 For me Iphones don’t render the best because of the screen size and my company logo image.
Nexus work so J
Thanks to chrome browser for screen size emulation feature !






Friday, September 27, 2013

Reporting Citrix user session into SQL - Alternative to edgesight

Updated 27/09/2013
Since we moved to  XenAPP 6.5 we noticed that was unable to get handy reports about usage what application users were loading. Not a bit fan of edgesight ! :(

After many months we have arrived at this solution, every 15mins a powershell script will query the XenApp farm and write the content up to SQL DB.

Assume you will know how to create table\permissions in the SQL database.
Pretty lean on my SQL leave it up to you to workout.
Created a database 'xenuserinfo' manually and then made sure it was selected when executing the SQL scripts

SQL Script:

/* To prevent any potential data loss issues, you should review this script in detail before running it outside the context of the database designer.*/
BEGIN TRANSACTION
SET QUOTED_IDENTIFIER ON
SET ARITHABORT ON
SET NUMERIC_ROUNDABORT OFF
SET CONCAT_NULL_YIELDS_NULL ON
SET ANSI_NULLS ON
SET ANSI_PADDING ON
SET ANSI_WARNINGS ON
COMMIT
BEGIN TRANSACTION
GO
CREATE TABLE dbo.XData
 (
 UsageDate datetime NULL,
 AccountName nvarchar(50) NULL,
 Application nvarchar(50) NULL,
 FarmName nvarchar(10) NULL
 )  ON [PRIMARY]
GO
ALTER TABLE dbo.XData SET (LOCK_ESCALATION = TABLE)
GO


CREATE TABLE dbo.XCount
 (
 UsageDate datetime NULL,
 SessionCount smallint NULL,
 FarmName nvarchar(10) NULL
 )  ON [PRIMARY]
GO
ALTER TABLE dbo.XCount SET (LOCK_ESCALATION = TABLE)

GO

COMMIT

Then I used the console to add permissions etc.

Now the powershell script that will run every 15mins, notice there are 2 entries to save me time when making graphs. At the 15 minute mark it looks backwards to see if there are any logons, if so then upload to database. Doubt it would get secondary launches (ie loading another app off same server).

Performing the session count as we are working in shared license environment = trust no-one!.

 Don't forget to install the SDK

#Add-PSSnapin citrix.xenapp.commands
#CPS Version
$time2 = Get-Date -Format "MMM dd yyyy HH:mm"
$time1 = Get-Date
$tminus15 = $time1.addminutes(-15)

# Check logons in the last 15 minutes
$allSessions = Get-XASession  | where-object -filterscript { ($_.state -eq 'Active') -or ($_.state -eq 'Disconnected') -and ($_.LogOnTime -gt $tminus15)} 
$FarmInfo=Get-xafarm 
$FarmName=$Farminfo.FarmName

 ## Hello SQL
$dbconn = New-Object System.Data.SqlClient.SqlConnection("Data Source=TheSQLServer; Initial Catalog=XenUserInfo; Integrated Security=SSPI")
$dbconn.Open()

 
 ## Write User App info to SQL
$allSessions | foreach {
$ACC=$_.accountname
$APP=$_.browsername
$LOT=$_.LogonTime.ToString("MMM dd yyyy HH:mm")
$CLN=$_.ClientName
$dbwrite = $dbconn.CreateCommand()
$dbwrite.CommandText = "INSERT INTO dbo.XLCPLData (UsageDate,AccountName,Application,FarmName,LogonTime,ClientName) VALUES ('$time2','$ACC','$APP','$Farmname','$LOT','$CLN')"
$dbwrite.ExecuteNonQuery()
$ACC=$null
$APP=$Null
$LOT=$Null
$CLN=$null
} 

 ## Write Session Count to SQL 
$dacount=$FarmInfo.SessionCount
$dbwrite1 = $dbconn.CreateCommand()
$dbwrite1.CommandText = "INSERT INTO dbo.XLCPLCount (UsageDate,SessionCount,FarmName) VALUES ('$time2', '$dacount','$Farmname')"
$dbwrite1.ExecuteNonQuery()

 ## Finished with SQL --- GoodBye
$dbconn.Close()
$allSession=$null

now off to create pretty graphs in excel

Update -

or.
Muck around with data in powershell ie generate csv etc.

## Hello SQL Grab my data from the last 30days
    $query = "select * FROM dbo.XLCPLData where LogonTime > GETDATE()-30 and Application != ''"
    $connection = New-Object System.Data.SqlClient.SqlConnection("Data Source=LCLABXENWIDS; Initial Catalog=XenUserInfo; Integrated Security=SSPI")
    $adapter = new-object system.data.sqlclient.sqldataadapter ($query, $connection)
    $table = new-object system.data.datatable
    $adapter.Fill($table) | out-null
    $applist=$table | sort-object Application -Unique | select -Property application
    
## Go generate pretty graphs or whatever.
## Use $table to see the list connections
## Use $applist to see the list of unique apps
##    Then you can use a foreach loop to generate content or csv.

Monday, October 31, 2011

XenApp 4.5 Summary Database Query stuff

Thanks to XENWIZ for the most of the code, SQL Query which I then export to CSV.

Point to Summary Database
Modify date
Grab important stuff like  appname, server, clientname, username, start time


SELECT LU_APPNAME.APPNAME,LU_SERVERNAME.SERVERNAME, SDB_SESSION.SESSIONSTART, SDB_SESSION.SESSIONEND, LU_CLIENT.CLIENTNAME, LU_USER.USERNAME
FROM
LU_APPNAME, SDB_SESSION, LU_USER, LU_SERVERNAME, LU_SERVER, LU_CLIENT
WHERE
LU_APPNAME.PK_APPNAMEID = SDB_SESSION.FK_APPNAMEID
AND LU_USER.PK_USERID = SDB_SESSION.FK_USERID
AND SDB_SESSION.FK_SERVERID = LU_SERVER.PK_SERVERID
AND LU_SERVERNAME.PK_SERVERNAMEID = LU_SERVER.FK_SERVERNAMEID
AND SDB_SESSION.FK_CLIENTID = LU_CLIENT.PK_CLIENTID
AND LU_CLIENT.CLIENTNAME != 'Console'
AND SDB_SESSION.SESSIONSTART Between '2011-10-27 14:00:00.000' and '2011-10-28 14:00:00.000'
ORDER BY SDB_SESSION.SESSIONSTART


The 'console' connection was causing my stats be a bit loopy.
also get a few blank appnames which I should exclude.