Monthly Archives: November 2011

Cataloging Exported packages from Frontrange Enteo / DSM 7 with Powershell.

This is just a quick powershell script I threw together to catalog exported packages.

By default when you export packages from Frontrange DSM (formerly Enteo) you end up with a large list of unique id’s with no real idea which package is which.

The below quick and dirty Powershell function will enumerate the xml file in each package folder and create a catalog which you can then export to csv if you wish.

To retrieve the list of packages and names, use the following command:

(where c:export is the location of your export)

get-DSMpackages -DirectoryPath "C:Export"

This will present itself as below:

To export the file to csv, try the following:

(where c:export is the location of your export, and you wish to save the csv file to c:exportcontents.csv)

get-DSMpackages -DirectoryPath "C:Export" | Export-Csv C:Exportcontents.csv -notypeinformation

This should create the csv file and look as follows:

Below is the function:

[sourcecode language=”Powershell”]
function get-DSMpackages{
param(
[Parameter(Mandatory = $true)]
[string]$DirectoryPath)

$result=@()

foreach ($folder in Get-ChildItem $directorypath | where {$_.psiscontainer -eq $true}){

[xml]$XMLBlock = get-content "$($folder.fullname)_ExpInfo.xml"
$name=$xmlblock.dsmexport.ArrayOfMdsObject.MdsObject.Name
if ($name -eq $null){
[xml]$XMLBlock = get-content "$($folder.fullname)_ExpInfo.xml"
$name=$xmlblock.dsmexport.ArrayOfMdsObject.mdsobject[0].name
}
$entry = New-Object PSObject -Property @{
Name=$Name
GUID=$folder.name}
$result+=$entry
}#end for
return ($result | sort name)
}#end function
[/sourcecode]

Importing Users to Citrix Edgesight User Groups from Active Directory.

I’ve blogged about Edgesight reporting previously, but in this case I needed to populate Edgesight groups from active directory and keep them up to date. This functionality is (rather strangely) not available in Edgesight and for this reason I decided to create a Powershell module to allow for automation of user group population from active directory.

Edgesight doesn’t seem to have any API’s or command line interfaces to hook into. For this reason my scripts are based on connecting to the Edgesight database and retrieving the information with SQL statements. This presented a really fun challenge for me as I’m an SQL novice. I learned quite a bit in a short period of time by writing this powershell module.

With the following module you can run scheduled tasks to connect to your edgesight database and add / amend your user groups with ease.

First, some caveats, warnings and limitations of Edgesight you should be aware of:

  • My SQL statements have been tested fully internally and work flawlessly, that being said Always backup your database before you attempt to use these modules.
  • Each Edgesight group has a unique GUID assigned when it is created, for this reason you must manually create the Edgesight groups before attempting to import users.
  • Each user has a unique identifier in Edgesight called a PRID, if Edgesight has not seen a user before, the PRID will not exist. As such, you cannot import a user who has not logged into the environment before.

Continue reading

Backup, Restore and Reset your XenApp 6 farms with powershell.

All good organizations should have at least one test XenApp farm, for testing changes before reaching your production environment. But quite often either changes made to the test environment are forgotten or changes to production are forgotten and your test environment goes from being a mirror of production, to differentiated and useless testing grounds.

Keeping the environments aligned is a needle and haystack event as you try to compare each policy, application and worker group manually and often by eye. Sometimes its just easier to rebuild the farm from a template of production.

I wrote the following PowerShell Module to overcome this differentiation over time by giving the support guys the ability to completely wipe a XenApp farm and re-import the production settings before beginning a test.

The basic process to this module is backup production, wipe test then restore to test. Below you will find all the neccessary information, the caveats and warnings around using these modules.

Thanks are due to @neilspellings and @kbaggerman for looking over the code and for the feedback.

Be warned, I wont be held responsible if you accidentally wipe your production farm. Always use backup-xafarm before you run reset-xafarm, regardless of the environment.

The following items are out of scope of this project:

  • Configuration logging is out of scope.
  • *Zone configuration is out of scope.

* zone configuration isn’t out of scope due to lack of interest, more out of lack of support in PowerShell to do so.

The following are necessities for this script to work:

  • All of your Xenapp applications must be published to worker groups, not individual servers.
  • you must run these commandlets from a XenApp server, running the management console to ensure you have access to the powershell snapins required.

Known issues:

  • The policy backups and restore take an age, this isn’t my code so I cant fix this. Grab a coffee while it runs.

Modules:

This powershell module is available in two formats:

1: The complete script, including the modules neccessary from the Citrix.GroupPolicy.Commands.psm1 module which I borrowed to from Citrix.

You can Download this here.

2: The Basic script, this script includes just my code and relies on you having to import the above module before running my module.

You can download this here.

A note for Citrix, I borrowed your module and included the code in the complete script to make this a complete solution. If you are unhappy with this in any way let me know and I’ll remove this module.

This module has three core components:

  • Backup-xafarm
  • Reset-xafarm
  • Restore-xafarm

Importing the module:

Simply copy the module to a local disk (to remove script signing prompts which you receive from network locations) and run the command you require depending on the module you wish to use:

1: Complete Module:

import-module .Citrix.XenApp.Backup.psm1

2: Basic Module:

import-module .Citrix.GroupPolicy.Commands.psm1
import-module .Citrix.XenApp.Backup.Basic.psm1

Follow the jump below to find a breakdown of the commands and how to use them:

Continue reading

Report Access Gateway connections using Citrix Edgesight, based on user groups.

I’ve covered this topic before, and with my previous solution you had the ability to report all access gateway connections natively through edgesight with ease. Recently though, as a service provider our customers have started requesting their own reports on user login details.

With the request in hand, I went back to the drawing board and attempted to Re-Engineer this task with limited success. In the end the quickest solution I found was to simply modify the “Session Details for a User Group” report to include the query I covered in my previous copy.

This wasn’t without peril, many of the labels will cease to work when you re-upload your report, so there was quite a bit of manual intervention to make the report pretty again.

I do intend to follow up with a powershell script to help populate Edgesight user groups from active directory. Check back later or follow me on twitter for updates.

I’ve shared this report file below for anyone to use and below you will find the steps to take in order to complete this task.

Note: Ensure you have configured your Access Gateway Web Interfaces to differenciate access gateways connections, I covered this before here:

1: Download the file here from box.net and place it somewhere you can easily access from your browser:

2: Open your browser and login to your edgesight instance:

3: Once logged in, choose the Configure tab:

4: From the left hand menu, Choose Custom Reports:

5: Choose Upload a Report:

6: Browse to your file, then fill in the details as below, Click Upload:

7: Confirm your new report has been uploaded, then click the report to do a test run:

 

Select your Desired values, then click Go:

 

the output show appear as below (account details have been omitted):

 

Enabling complete system memory dumps & more with Powershell

Configuring your systems for full crash dumps is extremely useful, especially in VDI / SBC environments where a number of core layers make up the users desktop.

To simplify the process, decisions around the page file and enabling the various crash dump methods I wrote the following powershell function to cover all these bases.

This powershell function is system managed page file aware, allows you to configure the pagefile by a multiple of physical ram and also allows you to configure either Crash on Ctrl Scroll lock, or NMI Crash dumps all in one place.You can also specify system recovery options on the command line to tell the system what to do in the event of a crash.

As this is quite a large function, I’ve included help test for reference. Below you will find some examples of how to use this function:

enable-completememorydump
This command will enable complete memory dumps using the system specified pagefile if possible.

enable-completememorydump -setpagefilesize -pagefilelocation “c:pagefile1.sys” -multiple 2 -forcerestart
This command forces the pagefile to be Ram * 2, sets the page file location to a new file (pagefile1.sys) and forces a restart on completion.

enable-completememorydump -setpagefilesize -forcerestart
This command forces the pagefile to be Ram * 1.5 (the default) and forces a restart on completion.

enable-completememorydump -setpagefilesize -forcerestart -CrashOnCtrlScroll -NMICrashdump
This command forces the pagefile to be Ram * 1.5 (the default), enables crash on ctrlscroll and nmicrashdumps and forces a restart on completion.

 enable-completememorydump -RebootafterCrash:$false -OverwriteExistingDebugFile:$false
This command enables complete memory dumps, but specifies not to restart after a crash dump, or overwrite an existing dump file.

Below you can see an example of the command line and expected output:

Click the link below to get a copy of the full function.

Continue reading