Tuesday, November 11, 2014

Teaching the XenApp 6.5 Servers to Reboot Themselves

As sleep is a commodity that I have been trying to bank, but all my customers want their servers to reboot at night.  If only there was a way to create an unholy combination of PowerCLI and Citrix Powershell commandlets that could do the work while I sleep.  This needs to be run from a box with both Citrix and PowerCli installed of course and you will need to sub in the IP of your Vcenter server.

asnp Citrix*
Add-PsSnapin VMware.VimAutomation.Core -ea "SilentlyContinue"

$servers=(get-xazone|get-xaserver -onlineonly|where{($_.logonmode -eq "ProhibitNewLogOnsUntilRestart") -and ((get-xaserverload $_.servername).load -eq 0)}).servername
foreach ($server in $servers){restart-vm -vm $server -confirm:$false}
start-sleep -s 600
while ((get-xazone|get-xaserver -onlineonly|where{($_.logonmode -eq "ProhibitNewLogOnsUntilRestart")}) -ne $null)


Monday, September 8, 2014

3 Line Pin to the TaskBar via PowerShell

So you want to pin some stuff to the user's taskbar quickly and with minimum code.  What do you do?  There are a whole lot of ugly VBS scripts out there and a few powershell scripts as well.  All are pretty fat.  Here is the minimal version of all them:

$Path = @("C:\Windows\system32\notepad.exe","C:\Windows\System32\shutdown.exe")
$Desktop = (New-Object -ComObject Shell.Application).NameSpace(0X0)
Foreach($itemPath in $Path){Foreach($ItemVerb in (($Desktop.ParseName($itemPath)).Verbs())){If($ItemVerb.Name.Replace("&","") -match "Pin to Taskbar"){$ItemVerb.DoIt()}}}

This is 3 lines of love for the taskbar.  If you switch the 'match' to 'Pin to Start Menu' the magic moves to the start menu.  Happy pinning.

Tuesday, March 18, 2014

The Missing RDL, Unique Users in Edgesight 5.4

I went looking for one of my old standby EdgeSight reports and it was gone.  I went and found it on an older installation.  So if you are looking for a Xenapp unique user count via edgesight, here it is...

Unique User Logon Counts

Monday, March 17, 2014

VMware Tools Beat Down My PVS-ed Servers

Citrix PVS is a magical technology that allows the OS to be streamed to you servers/desktops but it has a weak spot.  In PVS the network equals the disk.  My VMware goon was performing patching on my ESXi host and one of the patches included updated VMware tools.  VMware is configured to automatically update tools by default when the VMs start back up.  I ended up with servers full of VMs that would boot up and work for a minute or so and then lock up hard.  In troubleshooting, I discovered the tools CD was mounted on every box.  Two ways to avoid this.

Disable updating the tools in the VMware Update Manager

Tag the VMs with "No Update" via PowerCli

Foreach ($v in ( Get-Cluster "<CLUSTER NAME>" | get-vm)) {
$vm = $v | Get-View
$vmConfigSpec = New-Object VMware.Vim.VirtualMachineConfigSpec
$vmConfigSpec.Tools = New-Object VMware.Vim.ToolsConfigInfo
$vmConfigSpec.Tools.ToolsUpgradePolicy = "manual"


Good night and good luck...

Tuesday, March 4, 2014

OU to Environment Variable Script

So you want to know what OU your server is in to take some kind of action.  I like to load this data into an envrionment varibale so I can have it handy.  Here is my powershell solution:

$DS = New-Object System.DirectoryServices.DirectorySearcher
 $DS.Filter =  "(&(objectCategory=Computer)(Name=$env:computername))"
 $DN = ($DS.FindOne()).GetDirectoryEntry().DistinguishedName
 if ($ou.indexof(",OU="))  {$ou=$ou.substring(0,$ou.indexof(",OU="))}
 else  {$ou=$ou.substring(0,$ou.indexof(",DC="))}


Thursday, February 20, 2014

Exposing PVS data for BGinfo and Edgesight

Using Edgesight in a 6.5 environment with PVS, there are some conditions that need to be alerted on.  The quick and dirty way to get there is using an event log entry.  Described below is a startup script to capture PVS disk data in the event log and an environment variable.

To start, you need an event log source to use.  Creating a source is easy via powershell.  

New-EventLog –LogName Application –Source “Xenapp_Custom”

Technically you only need to this once, but it fails cleanly, allowing the command to be issued multiple times.

Set Some Defaults:

$disk="ID not found"

Read the data:

if(Test-Path $File){
$data=get-content $file
Foreach ($line in $data) {
if ($line.Contains("DiskName")){$iname=$line.replace("$","").replace("DiskName=","").replace(".vhd","")}
if ($line.Contains("WriteCacheType")){$wc=$line.replace("$","").replace("WriteCacheType=","")}

Evaluate the Vdisk mode and log it if we are unhappy:

switch ($wc)
"0" {$wc1="Private"}
"4" {$wc1="Standard"}
"1" {$wc1="Server";Write-EventLog –LogName Application –Source “XenApp_Custom” –EntryType Error –EventID 911 –Message “PVS ALERT. VDisk is set to Cache on server.  Immediate action is required to prevent an outage if this is a PROD image. Image: $iname”}
default {$wc1="OTHER";Write-EventLog –LogName Application –Source “XenApp_Custom” –EntryType Warning –EventID 911 –Message “PVS ALERT. Nonstandard VDisk configuration has been detected. Image: $iname”}

Capture the exception of a non PVSed disk

ELSE {$disk=$env:computername + "_Local"}

Write it to an environment variable so BGinfo can consume it and put it in the background


Like magic...

Friday, January 10, 2014

VMware Converter and Citrix Edgesight are not friends

Are your trying to run VMware converter on a Citrix server and getting a heaping helping of #FAIL?  VMware converter and the Edgesight agent do not play nice for a "Live" converstion.  The converter software crashes consistently when you are doing discovery against your VM candidate.  The easiest fix is to stop the "Citrix System Monitoring" services and the "Firebird" service prior to installing the converter software.  Once you have your copy, you can restart Edgesight without any issue.

Patrick Coughlin
Citrix Goon