• Category Widget (bottom-up)

  • The Front Page RSS Feed

    by Published on 07-06-2010 03:50 PM
    1. Categories:
    2. Citrix

    These are the parsing scripts referenced in the "Project: Poindexter" blog post from Xen-trifuge.com

    -You will need to rename the VPN DENIES.txt to VPN DENIES.RDL and upload it to reporting server.
    -You will also need to rename Netscaler.txt to Netscaler.ini before importing it into KIWI. If you have an existing installation of KIWI that you are using DO NOT import the netcaler.ini file. Also, you will need to use your own serial number and key, you will need to manually enter that information in.



    Sorry to send you over here but wordpress won't let me upload files!
    by Published on 05-26-2010 03:35 PM
    1. Categories:
    2. Citrix

    I recently came across a situation where I needed to clear users off a server in production for testing. Typically, we assign a load evaluator to keep new users from connecting to it and watch the server. When a user’s session becomes disconnected, we log the user off. This can take a while depending on how busy the server is and is about as exciting as watching grass grow. So, I thought “PowerShell can fix this problem!” Here’s the result. Download link follows code.


    # ================================================== ===============================
    #
    # NAME: CheckXenAppIsFree.ps1
    #
    # AUTHOR: Alain Assaf
    # DATE : 05/21/2009
    #
    # COMMENT: Script that will run on a locked down server and automatically disconnect users
    # until there are no more sessions.
    #
    # USAGE: .\CheckXenAppIsFree.ps1
    # ================================================== ================================

    # Prompt for server to watch
    if (($citrixserver -eq $null) -or ($citrixserver -eq “”)){
    $citrixserver=$(Read-Host “Enter Server to watch until no sessions exist.”)
    }

    # Setup Farm object
    $MetaFrameWinAppObject = 3
    $MetaFrameWinFarmObject = 1
    $myFarm = New-Object -com MetaFrameCOM.MetaFrameFarm
    $myFarm.Initialize($MetaFrameWinFarmObject)

    # Checking if user is a Citrix administrator
    If ($myFarm.WinFarmObject.IsCitrixAdministrator -eq 0) {
    Write-Output “You must be a Citrix admin to run this script`n”
    }

    # Checking that the Citrix server exists
    $MetaframeServers = $myFarm.Servers | Sort-Object -property ServerName | ? { $_.ServerName -like $citrixserver}
    If ($MetaframeServers -eq $null) {
    Write-Host “Invalid Citrix server” -ForegroundColor Red
    Write-Host “Exiting CheckXenAppIsFree” -ForegroundColor Red
    break
    }

    # Getting the currently assigned load evaluator
    $le = $MetaframeServers.AttachedLE
    $le.loaddata(1)
    $LEName = $le.LEName
    $XenAppServerName = $citrixserver.ToUpper()

    # If the LE isn’t set to Lockdown, then this script will exit
    If ($LEName -eq ‘Lockdown’) {
    Write-Host “$XenAppServerName has ‘$LEName’ attached.” -ForegroundColor White
    } else {
    Write-Host “$XenAppServerName does not have a Lockdown LE attached. It has ‘$LEName’ attached.” -ForegroundColor White
    Write-Host “Exiting CheckXenAppIsFree” -ForegroundColor Red
    break
    }

    # Get the current session count
    $sessCount = $MetaframeServers.SessionCount

    # Check for disconnected users. If none, wait 10 minutes and check again
    # If there are disconnected users. Log them off. Continue until there are no more logged in sessions.
    while ($sessCount -ge 0) {
    $MetaframeServers = $myFarm.Servers | Sort-Object -property ServerName | ? { $_.ServerName -like $citrixserver}
    $sessCount = $MetaframeServers.SessionCount
    Write-Host “Current session Count = $sessCount on $XenAppServerName” -ForegroundColor White
    if ($sessCount -eq 0) { Write-Host “$XenAppServerName is free of users” -ForegroundColor White
    break
    } else {
    $disconnected = @()
    Write-Host “Checking for disconnected users on $XenAppServername” -ForegroundColor White
    $disconnected = @($myfarm.Sessions | Where-Object {$_.SessionState -eq 5 -and $_.ServerName -eq $citrixserver})
    if ($disconnected[0] -eq $null) {
    Write-Host “There are no currently disconnected sessions on $XenAppServerName” -ForegroundColor White
    Write-Host “Waiting 10 minutes” -ForegroundColor Red
    Start-Sleep -Seconds 600
    } else {
    Write-host “Logging off disconnected users from $XenAppServerName” -ForegroundColor White
    $i = 0
    foreach ($user in $disconnected) {
    $namedUser = $disconnected[$i].Username
    write-host “Logging off $namedUser” -ForegroundColor White
    $user.Logoff($false)
    $sessCount–
    $i++
    }
    }
    }
    }

    You can download a copy here.

    Thanks,
    Alain
    by Published on 05-26-2010 03:30 PM

    Documentation is a vital (yet rarely loved) part of systems administration/engineering. Exhaustively documenting Citrix can turn your hair white. There are farm-wide settings, polices, application publishing properties, zone configuration, and that’s just the beginning.

    We are in the midst of architecting a new Citrix environment where I work and we are taking advantage of this to review everything we have done before and changing it if needed. We’re also attempting to document every facet of our new environment which includes, Provisioning (DHCP), XenApp, XenServer, XenDesktop, AppSense, Netscalers, Web Interface, and MS App-V.

    For this post, I’m providing a PowerShell script I modified from Kent Finkle that will capture a Citrix Policy and what it’s applied to in a Word document. The script will also export the Citrix policy and its filter (what it’s applied to) to 2 XML files that can be used to recreate or restore the configuration if it’s lost.
    NOTE: This script assumes that the XenApp PowerShell Commands are installed on the server you’re running the script from. You can download them from www.citrix.com.

    Here’s the script (download link at end of post):

    #================================================= ========= #
    # NAME: get-citrixpolicy.ps1
    #
    # AUTHOR: Alain Assaf
    #
    # DATE : 5/11/2010
    #
    # SOURCE: Author: Kent Finkle http://kentfinkle.com/CreateSaveWordDoc.aspx
    # COMMENT: Output a Citrix Policy to a Word document.
    # Assumes XenApp Commands are installed on source server
    # VERSION: 1.0.0 – Initial script
    # VERSION: 1.0.5 – Added policy filter and xml export of policy and filter
    #================================================= =========

    #Load XenApp Commands
    Add-PSSnapin Citrix.XenApp.Commands

    #Set variables
    $docpath = “\Architecture\Citrix\policies”
    $polname = ‘CITRIX POLICY NAME’
    $hname = $env:computername
    $uname = $env:username
    $a = get-date –format g
    $b = get-date -uformat “%m%d%Y”

    #Test path & create if not present
    if (!(Test-path -path $docpath)) { new-item $docpath -type directory | out-null }

    $objWord = New-Object -comobject Word.Application
    $objWord.Caption = “Test Caption”
    $objWord.Visible = $True
    $objWord.Activate()

    $farm = get-xafarm

    $objDoc = $objWord.Documents.Add()
    $objSelection = $objWord.Selection
    $objSelection.Font.Name = “Arial”
    $objSelection.Font.Size = “18″
    $objSelection.TypeText(“Citrix Policy Report”)
    $objSelection.TypeText(” for Farm: ” + $farm.FarmName)
    $objSelection.TypeParagraph()
    $objSelection.Font.Size = “8″
    $objSelection.Font.Italic = $True
    $objSelection.TypeText(“Script run on: ” + $hname)
    $objSelection.TypeText(” by: ” + $uname)
    $objSelection.TypeText(” at ” + $a)
    $objSelection.Font.Italic = $False
    $objSelection.TypeParagraph()

    $objSelection.Font.Size = “10″
    $policy = Get-XAPolicyConfiguration -PolicyName $polname
    $objSelection.Font.Bold = $True
    $objSelection.TypeText(“Citrix Policy: ” + $policy.PolicyName)
    $objSelection.Font.Bold = $False
    $objSelection.Font.Size = “10″

    $outpol = $policy | Out-String
    $objSelection.TypeText(“” + $outpol)
    $objSelection.TypeParagraph()

    $policyfilter = Get-XAPolicyFilter -PolicyName $polname
    $objSelection.Font.Bold = $True
    $objSelection.TypeText($policyfilter.PolicyName + ” policy applied to:”)
    $objSelection.Font.Bold = $False
    $objSelection.Font.Size = “10″

    $outpolfilter = $policyfilter | Out-String
    $objSelection.TypeText(“” + $outpolfilter)
    $objSelection.TypeParagraph()

    $doctitle = $farm.FarmName + “_” + $policy.PolicyName + “_” + $b
    $objDoc.SaveAs([ref] “$docpath\$doctitle.doc”)
    $objWord.Quit()

    $poltitle = $farm.FarmName + “_” + $policy.PolicyName + “_Policy” + “_” + $b
    $polfiltertitple = $farm.FarmName + “_” + $policyfilter.PolicyName + “_PolicyFilter” + “_” + $b

    export-clixml -path “$docpath\$poltitle.xml” -InputObject $policy
    export-clixml -path “$docpath\$polfiltertitple.xml” -InputObject $policyfilter

    Here’s a sample of the Word document (sanitized for public consumption):



    The intention is to run this script periodically to provide documentation and a backup of all the policies applied to a farm. I encourage you to explore the PowerShell commands provided by Citrix. You will be able to document every aspect of your farm and also have an easy way to backup/restore the information as needed.

    Script is available below.

    Thanks,
    Alain