XenDesktop 7 custom icon for published application

This process will add a new icon to your XenDesktop database that you can use with your applications.

Convert your logo file to icon here http://converticon.com/

asnp citrix*

Get-CtxIcon -FileName C:\Temp\youriconfile.ico |New-BrokerIcon
# Note the Uid

Get-BrokerApplication -name "yourapplication" | Set-BrokerApplication -IconUid Uid

Netscaler VPX on ESX looses network connectivity

Today we ran into an issue with Netscaler VPX installed on ESX. It lost network connectivity, and after a reboot it would have random packet loss for a while. And in console we could see it had troubles keeping the interface up.

Turns out there was an ongoing patching of ESX, and the result was troubles with Netscaler. Google brought https://communities.vmware.com/thread/492945 to the table, which seems to be a working work around.


Powershell check service status and eventually start if stopped

I mostly use this script for checking all XenDesktop app hosts if print spooler is running, and if its not it will try to start it.

First it finds all registered hosts from XenDesktops, and then query the spooler service and eventually try to start it if it is stopped.

To check/start other services, just enter servicename in $service variable.

$xendesktopController = "deliverycontroller.domain.local"
$onlineHosts = @()
$service = "spooler"
## This function gets all online hosts with status as registered in XenDesktop. This way we dont have to wait for hosts thats not accepting users anyways.
## Result is output to a CSV on c:\scripts\
function getOnlineHosts {
Write-host -ForegroundColor Yellow -BackgroundColor Black "*********************************************"
Write-Host -ForegroundColor Yellow -BackgroundColor Black "** Getting online hosts.....be patient.... **"
Write-Host -ForegroundColor Yellow -BackgroundColor Black "*********************************************"
$psremote = New-PSSession -ComputerName $xendesktopController
Invoke-Command -Session $psremote { asnp citrix* }
Invoke-Command -Session $psremote -scriptblock { Get-BrokerMachine -Filter { RegistrationState -eq 'Registered' } | Select-Object dnsName} | Export-Csv c:\scripts\onlinehosts.csv


## Reads CSV and checks spooler status on each host, if not running, service is started.
function checkAndStartSpooler
$onlineHosts = Import-Csv c:\scripts\onlinehosts.csv
foreach ($h in $onlineHosts)
$pshost = $h.DNSName
Write-Host -BackgroundColor Black "Checking spooler status on: " $h.DNSName
Invoke-Command -ComputerName $pshost {
$serviceStatus = Get-Service -Name Spooler
if ($serviceStatus.Status -ne "Running")
Start-Service -Name Spooler
Write-host -ForegroundColor Red -BackgroundColor Black "Started Spooler on: " $env:COMPUTERNAME
Write-host -ForegroundColor Green -BackgroundColor Black "Spooler checked out fine on: " $env:COMPUTERNAME

## Calling functions.


XenDesktop monitor registration state

These days, we have had a lot of trouble with a XenDesktop 7.1 farm that have VM’s unregister with controller and in many times leaving the VM “half dead”. So i spent a few days with refreshing Studio to watch for VM’s going in to unregistered state. Today I spent a few minutes and created a script that does the same thing in PoSh. Refreshing every 30 seconds.

This probably could be better written on a one-liner, but I really dont like one-liners they are messy :)

asnp citrix*
$i = 1
while ($i -eq 1) {
Get-BrokerDesktop|select MachineName,RegistrationState|sort RegistrationState|ft
Start-Sleep -Seconds 30

Remote initialize and format newly added harddrive

Handy little script that initializes your newly added harddisk and then format it.

function initalizeDisk ($dnsname)
$psremote = New-PSSession $dnsname
Invoke-Command -Session $psremote { Get-Disk |

Where partitionstyle -eq 'raw' |

Initialize-Disk -PartitionStyle MBR -PassThru |

New-Partition -AssignDriveLetter -UseMaximumSize |

Format-Volume -FileSystem NTFS -NewFileSystemLabel "WriteCache" -Confirm:$false



Print test page to all your printers from Powershell

I recently had a task, requiring me to print a testpage to all printer queues on a printserver. With somewhere around 150 queues, this is certainly something i won’t do manually. So i created a little snippet to perform my task.

I know this could be done in one line, but I really dislike that way of writing code.

$printers = Get-Printer | select Name

foreach ($printer in $printers) {

Write-Host "Spooling Test Page to Printer: " $printer.name

rundll32 printui.dll,PrintUIEntry /k /n $printer.name


Duplicate all applications in XenDesktop 7 to new delivery group

This little powershell script will get all current applications from your current delivery group, and duplicate it to a new. 

asnp citrix*

$apps = Get-BrokerApplication | select BrowserName

foreach ($app in $apps)
$in = Get-BrokerApplication -BrowserName $app.BrowserName
Write-Host “Duplicating app to new deliverygroup: ” $in.BrowserName
#$in | Add-BrokerApplication -DesktopGroup “Server 2012v2”