Paul McCran's

Portfolio
Here are three useful powershell commands for helping to diagnose disconnection issues.  Insert the computer name after "-ComputerName".  Run each section separate.

The trace file will grow to 1GB and then repeat until stopped.

Once you have stopped the trace, copy the ETL file to a share and open the file with Microsoft Message Analyser.  Save and export the file in to .cap format and open with Wireshark.

I have been working on a script that allows you to add the computer names to a text file and will create a trace of each of those computers.  It also allows you to add a username and have the script query a Delivery controller for the associated Citrix machine name and then run a trace.  I'll post that version when complete.


  #START THE TRACE
 
   function Disable-ExecutionPolicy {($ctx = $executioncontext.gettype().getfield("_context","nonpublic,instance").getvalue( $executioncontext)).gettype().getfield("_authorizationManager","nonpublic,instance").setvalue($ctx, (new-object System.Management.Automation.AuthorizationManager "Microsoft.PowerShell"))}  Disable-ExecutionPolicy  .runme.ps1
  
   Invoke-Command -ComputerName   {  
            powershell -command{
            $test=test-path C:\NetworkTrace
            if ($test=test-path C:\NetworkTrace) {
            Remove-Item C:\NetworkTrace -Recurse -Force -EA SilentlyContinue -Verbose
            new-item c:\NetworkTrace -itemtype directory
            netsh trace start persistent=yes capture=yes report=yes maxSize=1024 fileMode=circular overwrite=yes  tracefile=c:\NetworkTrace\nettrace-boot.etl
          }
            else {
           new-item c:\NetworkTrace -itemtype directory
           netsh trace start persistent=yes capture=yes report=yes maxSize=1024 fileMode=circular overwrite=yes  tracefile=c:\NetworkTrace\nettrace-boot.etl
           }                  
                               }                         
         }

#STOP THE TRACE
            Invoke-Command -ComputerName {  
            powershell -command{
            $test=test-path C:\NetworkTrace
            if ($test=test-path C:\NetworkTrace) {
            netsh trace stop
           #new-item c:\NetworkTrace -itemtype directory
            #netsh trace start persistent=yes capture=yes report=yes persistent=Yes maxSize=1024 MB fileMode=circular overwrite=yes  tracefile=c:\NetworkTrace\nettrace-boot.etl
          }}}


#REMOVE THE TRACE
            Invoke-Command -ComputerName  {  
            powershell -command{
            $test=test-path C:\NetworkTrace
            if ($test=test-path C:\NetworkTrace) {
            Remove-Item C:\NetworkTrace -Recurse -Force -EA SilentlyContinue -Verbose
            #new-item c:\NetworkTrace -itemtype directory
            #netsh trace start persistent=yes capture=yes report=yes persistent=Yes maxSize=1024 MB fileMode=circular overwrite=yes  tracefile=c:\NetworkTrace\nettrace-boot.etl
          }}}

MIGRATE A VM FROM XENSERVER to NUTANIX ACROPOLIS

1.      Create a Container called “XEN” on the Nutanix Appliance Prism console

2.      In the Prism menu, select the “Settings” cog icon on top right side of menu and select “Filesystem Whitelists”

3.      Add the XenServer Management IP and subnet eg (x.x.x.x/x.x.x.0). I added the storage IP and subnet also but this may not be required.

4.      On the XenServer that you are migrating from, add a new SR (NFS) and point it to the nutanix / Xen container that you created:

5.      Shut down the VM to be migrated in XenCenter:

6.      Right Click VM after shut down. Export and run through wizard to export to storage on the XenServer Console host

7.      Ok through XenServer migration prompts until “Configure networkin2g options for the transfer VM” window and select “Management Bond” in the drop down “Network” settings.  Choose auto allocate IP or specific a static IP to be used.

8.      Untick Verify Export on Completion

9.      In XenServer Select  “View” then select “Hidden Objects”.  Check the Event Tab log to make sure that the Transfer VM has been created.  Go the console of the Transfer VM and make sure that the VM has picked up a DHCP address so that it can export the VM.

10.   In XenServer, click on “Notifications” and “Events” log.  Click on the Down arrow next to the export VM event and make sure that the status is set to “transferring virtual disk”

11.   Wait until this job is completed.  This can take a few hours.

12.   Detach the virtual disk for the migrated VM in the XenServer console.  You will see the warning “Detaching this virtual disk will remove the association between it and the VM while preserving the disk and its data.  Would you like to continue?”

13.   Go to the SR node in XenServer where the disk is located and select the disk that you detached from the VM.  Right Click and “Move” the Disk to the Nutanix SR that you mounted earlier

14.   Check the XenServer Events tab and wait until the move has completed.  This can take a couple of hours depending on the size of VM.

15.   Once completed, mark the VM in XenServer as “Do not switch on”

16.   Use WinSCP to connect to a CVM  IP and username password

17.   Or username admin and configured password

18.   Double click on the XEN container and copy the file name and container name into the command eg:

19.   image.create VMDRIVE source_url=nfs://127.0.0.1/XEN/51037c42-6da5-cb48-964b-6c226b9ae643/de7bc643-5e97-46b3-bded-a4bfee2ba5a0.vhd container=XEN image_type=kDiskImage wait=true

20.   Putty to admin console

21.   Logon with appropriate username and password

22.   Logon and run:   Acli

23.   Copy and paste the above command and wait and hour or so until the conversion has completed:

24.   This operation will remain at “Pending” status until complete.  Do not try to run the command again or kill the process.  It is not possible to kill the task.

25.   You will also notice an image creation process queued in the Prism Console

 
I have been working with a client on a XenApp 6 to 7.11 (Seven Eleven) migration project recently.  The client has a large list of shortcuts which were published in their existing Farm and staff were used to accessing content via those shortcuts.  This presented a challenge and was potentially going to slow down the migration time until all shortcuts had been published on the new 7.11 site.

My approach to this challenge was to use a combination of powershell and Excel to automatically create the new published content and apps.  I did this by extracting a list of published applications on the client's existing XenApp 6.5 Farm and saving the data into and Excel Spreadsheet

The article will describe the the method and Powershell script that I used to automatically publish all of the application shortcuts within the Excel Spreadsheet.  This should be used as a guide and I'm sure many of you will be able to tweak and improve the Powershell code or perhaps remove the requirement for Excel.

Method:

Installed Excel on one of my Delivery Controllers

Copied the Exported Application Data and removed unwanted column information so that I was left with (Publication Name, Command Executable, Command path, Working Directory)

From the Delivery Controller, launched Powershell and ran Get-BrokerDeliveryGroup. Noted the UID of the delivery group

Copied the Shortcut.excel spreadsheet into a directory called "Shortcuts"

Modified the powershell script to imclude the path to the excel file and the UID of the delivery group.


POWERSHELL SCRIPT

$rowcount=0
$xl = New-Object -COM "Excel.Application"
$xl.Visible = $true
$wb = $xl.Workbooks.Open("C:\shortcuts\shortcuts.xlsx")
$ws = $wb.Sheets.Item(1)
$rowcount = $ws.UsedRange.Rows.Count
$wb.Close()
$xl.Quit()

$FilePath = "C:\shortcuts\shortcuts.xlsx"
$SheetName = "Sheet1"
$objExcel = New-Object -ComObject Excel.Application
$objExcel.Visible = $true
$WorkBook = $objExcel.Workbooks.Open($FilePath)
$WorkSheet = $WorkBook.sheets.item($SheetName)
$Row=1
$NAMEVAR=1
$EXEVAR=2
$PATHVAR=3
$WRKDIRVAR=4
while($row -le $rowcount){
$CommandLineEXE=$worksheet.Rows.Item($ROW).Columns.Item($EXEVAR).Text
$CommandLinePATH=$worksheet.Rows.Item($ROW).Columns.Item($PATHVAR).Text
$WORKDIR=$worksheet.Rows.Item($ROW).Columns.Item($WRKDIRVAR).Text
$Name=$worksheet.Rows.Item($Row).Columns.Item($NAMEVAR).Text
$PubNameVAR=$worksheet.Rows.Item($Row).Columns.Item($NAMEVAR).Text
$pspubnameVAR="-PublishedName "+$PubName
$psnameVAR=$NameVAR
$appVAR=New-BrokerApplication -ApplicationType “HostedOnDesktop” -CommandLineArguments $CommandLinePATH -CommandLineExecutable $CommandLineEXE -CpuPriorityLevel "Normal" -DesktopGroup 5 (This it the delivery group UID) -Enabled $True -MaxPerUserInstances 0 -MaxTotalInstances 0 $psname -Priority 0 -SecureCmdLineArgumentsEnabled $True -ShortcutAddedToDesktop $False -ShortcutAddedToStartMenu $False -workingdirectory $workdir -UserFilterEnabled $False -Visible $True -WaitForPrinterCreation $False -Description "Keywords:auto"
Add-BrokerApplication $appVAR -DesktopGroup "NAME OF YOUR DESKTOP DELIVERY GROUP"
$Row+=1
}

$workbook.close
$objexcel.close


EXCEL SPREASHEET COLUMNS

Column A - Exported Publication's Name
Column B - Exported Publication's Command Line
Column C - Exported Publication's Path
Column D - Exported Publication's Working Directory

Save the spreadsheet to the path specified in the script.

Run the script











Follow this Citrix Article:

http://support.citrix.com/article/CTX136668

Get-brokersession | Where-Object {$_.sessionstate -eq "Disconnected" -and $_.sessionstatechangetime -lt (Get-date).AddHours(-4)} | stop-brokersession


Use this command to stop sessions that have been disconnected for 4 hours. This could be useful when the Timings you want are not accepted by the Sessions GPO setting. 


When you add an App-V sequenced package into the new XenApp 7.8 integrated App-V library, you will need to make sure that the location you are importing the packages from is a network Share.  If you do not import the package from a network share, you'll notice that the powershell command to import the package is run, but the Studio screen appears blank and the application is not added.

On further investigation,  the Studio Console Log will display "Successful" for the import.  The Windows event log will show no details of any error.  You can launch Powershell from Studio and type the command:

Get-AppLibAppVpackage

This will display a list of the imported App-V packages.  You may notice that there will be entries in there even though there is nothing in Studio.  Notice the erroneous metadata entries (Your failed import attempts) and zero package GUID information.  When you try to remove these entries using Remove-AppLibAppVPackage -UID, it will not work.  

Citrix will implement a patch for this issue, but in the meantime, please be aware that if you add a package from any location that isn't a share, it will not display an error and it may create erroneuos metadata entries.

  • Check the location that you import the Sequenced Packages from is a Network Share
  • Check the Citrix Application Library Service is running on the Delivery Controllers


Your XenApp/Xendesktop services may be running, but how can you check that they are working as they should?  Do the following:

Launch Studio Console from a Desktop Delivery Controller and Select the Launch Powershell option

Check each service in turn with these commands:

Get-ConfigServiceStatus
Get-BrokerServiceStatus
Get-HypServiceStatus
Get-AcctServiceStatus
Get-ProvServiceStatus
Get-AnalyticsServiceStatus
Get-MonitorServiceStatus
Get-AdminServiceStatus
Get-logServiceStatus
Get-SfServiceStatus
Get-EnvTestServiceStatus
GetADIdentityService

If they return as "OK", then it indicates the Service is running and connected with the database.

Previous PostOlder Posts Home