Timothy Cochran Posted October 3, 2014 Share Posted October 3, 2014 Is there currently a way of exporting and importing application settings in XenDesktop/XenApp 7.x? I know polices can be easily exported/imported via PowerShell, is there such a thing for Applications? Link to comment
2 Timothy Cochran Posted October 8, 2014 Author Share Posted October 8, 2014 Made some changes to the code, also incorporated the troubleshooting and fixed from users of this forum post that were provided. Thank you all for your contributions! Glad this has been useful. :) <## File Name : XenAppExport.ps1# Description:# # Exporting Application Data and Icons to XML format. This will allow# users to import applications and the applications settings in another# site for testing or site replication.#># Adding Citrix SnapinsAdd-PSSnapin Citrix*# Setting start up location$Location = $MyInvocation.MyCommand.Path -replace $MyInvocation.MyCommand.Name,"";set-location $Location;# Grabs applications$apps = Get-BrokerApplication -MaxRecordCount 2147483647$Results = @()foreach($app in $apps){ # Building Properties for each application $Properties = @{ AdminFolderName = $app.AdminFolderName AdminFolderUid = $app.AdminFolderUid ApplicationName = $app.ApplicationName ApplicationType = $app.ApplicationType AssociatedDesktopGroupPriorities = $app.AssociatedDesktopGroupPriorities AssociatedDesktopGroupUUIDs = $app.AssociatedDesktopGroupUUIDs AssociatedDesktopGroupUids = $app.AssociatedDesktopGroupUids AssociatedUserFullNames = $app.AssociatedUserFullNames AssociatedUserNames = $app.AssociatedUserNames AssociatedUserUPNs = $app.AssociatedUserUPNs BrowserName = $app.BrowserName ClientFolder = $app.ClientFolder CommandLineArguments = $app.CommandLineArguments CommandLineExecutable = $app.CommandLineExecutable CpuPriorityLevel = $app.CpuPriorityLevel Description = $app.Description Enabled = $app.Enabled IconFromClient = $app.IconFromClient EncodedIconData = (Get-Brokericon -Uid $app.IconUid).EncodedIconData # Grabs Icon Image MetadataKeys = $app.MetadataKeys MetadataMap = $app.MetadataMap Name = $app.Name PublishedName = $app.PublishedName SecureCmdLineArgumentsEnabled = $app.SecureCmdLineArgumentsEnabled ShortcutAddedToDesktop = $app.ShortcutAddedToDesktop ShortcutAddedToStartMenu = $app.ShortcutAddedToStartMenu StartMenuFolder = $app.StartMenuFolder UUID = $app.UUID Uid = $app.Uid UserFilterEnabled = $app.UserFilterEnabled Visible = $app.Visible WaitForPrinterCreation = $app.WaitForPrinterCreation WorkingDirectory = $app.WorkingDirectory } # Stores each Application setting for export $Results += New-Object psobject -Property $properties}# Setting File name with time stamp$Date = Get-Date$FileName = $Date.ToShortDateString() + $Date.ToLongTimeString()$FileName = (($FileName -replace ":","") -replace " ","") -replace "/",""$FileName = "Apps" + $FileName + ".xml"# Exporting results$Results | export-clixml .\$FileName <## File Name : XenAppImport.ps1# Description: Importing Application Data and Icons from exported xml file.## Notes : Getting Delivery Group from Arguments# I.e. .\XenAppImport.ps1 "<Delivery Group Name>" .\<AppExportedXMLFile>.xml#># Adding Citrix Snapins Add-PSSnapin Citrix* # Setting start up location$Location = $MyInvocation.MyCommand.Path -replace $MyInvocation.MyCommand.Name,""set-location $Location# Delivery Group for imported location$dg = Get-BrokerDesktopGroup $args[0]#Importing Application Data$apps = Import-Clixml $args[1]foreach ($app in $apps){ #Resetting failure detection failed = $false #Publishing Application Write-Host "Publishing APPLICATON:" $app.PublishedName if ($app.CommandLineArguments.Length -lt 2) {$app.CommandLineArguments = " "} #Display Application Settings write-host -ForegroundColor Cyan "BrowserName : " $app.BrowserName write-host -ForegroundColor Cyan "ComdLineExe : " $app.CommandLineExecutable write-host -ForegroundColor Cyan "Description : " $app.Description write-host -ForegroundColor Cyan "ComdLineArg : " $app.CommandLineArguments write-host -ForegroundColor Cyan "Enabled : " $app.Enabled write-host -ForegroundColor Cyan "Name : " $app.Name write-host -ForegroundColor Cyan "UserFiltEna : " $app.UserFilterEnabled write-host -ForegroundColor Cyan "WorkingDire : " $app.WorkingDirectory write-host -ForegroundColor Cyan "Published : " $app.PublishedName write-host -ForegroundColor Cyan "ClientFolder: " $app.ClientFolder Try{ #Prep for Application Import - Removing Null values # * Not just some null value, any null values seems to crash this processes. # * Application folders screw this field up, had to use PublishedName for -Name property. $MakeApp = 'New-BrokerApplication -ApplicationType HostedOnDesktop' if($app.BrowserName -ne $null){$MakeApp += ' -BrowserName $app.BrowserName'} if($app.CommandLineExecutable -ne $null){$MakeApp += ' -CommandLineExecutable $app.CommandLineExecutable'} if($app.Description -ne $null){$MakeApp += ' -Description $app.Description'} if($app.ClientFolder -ne $null){$MakeApp += ' -ClientFolder $app.ClientFolder'} if($app.CommandLineArguments -ne $null){$MakeApp += ' -CommandLineArguments $app.CommandLineArguments'} if($app.PublishedName -ne $null){$MakeApp += ' -Name $app.PublishedName'} if($app.UserFilterEnabled -ne $null){$MakeApp += ' -UserFilterEnabled $app.UserFilterEnabled'} if($app.Enabled -ne $null){$MakeApp += ' -Enabled $app.Enabled'} if($dg -ne $null){$MakeApp += ' -DesktopGroup $dg'} if($app.WorkingDirectory -ne $null){$MakeApp += ' -WorkingDirectory $app.WorkingDirectory'} if($app.PublishedName -ne $null){$MakeApp += ' -PublishedName $app.PublishedName'} #Creating Application Invoke-Expression $MakeApp | Out-Null } catch { write-host -ForegroundColor Red $_.Exception.Message write-host -ForegroundColor Red $_.Exception.ItemName write-host -ForegroundColor Red "Error on " $app.BrowserName write-host -ForegroundColor Red "Error on " $app.CommandLineExecutable write-host -ForegroundColor Red "Error on " $app.Description write-host -ForegroundColor Red "Error on " $app.CommandLineArguments write-host -ForegroundColor Red "Error on " $app.Enabled write-host -ForegroundColor Red "Error on " $app.Name write-host -ForegroundColor Red "Error on " $app.UserFilterEnabled $failed = $true } if($failed -ne $true) { #Importing Icon $IconUid = New-BrokerIcon -EncodedIconData $app.EncodedIconData #Setting applications icon Set-BrokerApplication $app.PublishedName -IconUid $IconUid.Uid write-host -ForegroundColor Green "Working on Icon" $IconUid.Uid "for application:" $app.PublishedName # Adding Users and Groups to application associations If($app.AssociatedUserNames -ne $null) { Try { $users = $app.AssociatedUserNames foreach($user in $users) { write-host -ForegroundColor Yellow "Adding User or Group:" $user "for application:" $app.PublishedName Add-BrokerUser -Name "$user" -Application $app.PublishedName } } catch { write-host -ForegroundColor Red $_.Exception.Message write-host -ForegroundColor Red $_.Exception.ItemName write-host -ForegroundColor Red "Error on User " $user "for application:" $app.PublishedName } } }} 8 Link to comment
4 Kaspars Vilde Posted June 3, 2018 Share Posted June 3, 2018 Hi guys. I modified both original scripts, because rarely a Citrix site has only one Delivery Group. There were 2 main problems with original scripts - 1)export script exports all applications from all Delivery groups which in my opinion is not how it should work especially if in import script you specify specific DG. I modified the export script so it asks which Delivery group you want export. 2)import script had a problem that if you already had published application with same name it would fail to create those applications. I modified the script to let DDC create it's own BrowserName. Also i modified the icon change and add user part because it would not find the applications after my modifications. How it works: 1)First export apps from specific Delivery Group with export_apps.psi script 2)Copy the created export App<data>.xml file to new DDC controller 3)Create exactly the same Application folder structure as in original Citrix site 4)Create new Catalog using same MCS image or remote server and create new Delivery Group. Delivery Group name can differ from original site. 5)Run the import_apps.ps1 from power shell like this - ./import_apps.ps1 "New Delivery Group Name" "Apps<date>.xml" Works great on 7.15.200 version. I migrated from 7.12 DDC controllers. Hope this helps someone! export_apps.ps1 import_apps.ps1 4 Link to comment
1 Ben Tusa Posted April 5, 2019 Share Posted April 5, 2019 On 6/3/2018 at 9:30 AM, Kaspars Vilde said: Hi guys. I modified both original scripts, because rarely a Citrix site has only one Delivery Group. There were 2 main problems with original scripts - 1)export script exports all applications from all Delivery groups which in my opinion is not how it should work especially if in import script you specify specific DG. I modified the export script so it asks which Delivery group you want export. 2)import script had a problem that if you already had published application with same name it would fail to create those applications. I modified the script to let DDC create it's own BrowserName. Also i modified the icon change and add user part because it would not find the applications after my modifications. How it works: 1)First export apps from specific Delivery Group with export_apps.psi script 2)Copy the created export App<data>.xml file to new DDC controller 3)Create exactly the same Application folder structure as in original Citrix site 4)Create new Catalog using same MCS image or remote server and create new Delivery Group. Delivery Group name can differ from original site. 5)Run the import_apps.ps1 from power shell like this - ./import_apps.ps1 "New Delivery Group Name" "Apps<date>.xml" Works great on 7.15.200 version. I migrated from 7.12 DDC controllers. Hope this helps someone! export_apps.ps1 import_apps.ps1 Running the export script on a 7.15 controller and getting this error, thoughts? At line:1 char:23 + foreach($app in $apps) + ~ Missing statement body in foreach loop. + CategoryInfo : ParserError: (:) [], Paren + FullyQualifiedErrorId : MissingForeachStatement 1 Link to comment
1 Edgar Marcha1709159915 Posted June 13, 2019 Share Posted June 13, 2019 37 minutes ago, Edgar Marcha1709159915 said: Follow-up test: I ran a query on my Test App Get-BrokerApplication -ApplicationName "DCR Test" It has an Null value for AdminFolderName - My Apps defaults under applications (no additonal sub-folder structure) For TEST - I created an Application Folder for this app called TESTQA Run Query Again: Now you see a value TESTQA I created same subfolder in my receiving import site - XD 715.3 LTSR Now it works: The Script need to ignore Null value for AdminFolderName. Any assistance will be great, Thanks My Work Around is to rem out following from properties collection in export_apps.ps1 - and this works for me. $Properties = @{ #AdminFolderName = $app.AdminFolderName #AdminFolderUid = $app.AdminFolderUid ApplicationName = $app.ApplicationName Note: If you have sub-folders for your apps this will not work - it will drop apps in default Applications under Application Folders. Script need a routine to recognize this. 1 Link to comment
1 Blair McLean1709161693 Posted April 20, 2020 Share Posted April 20, 2020 On 3/7/2020 at 7:10 AM, Pete Smith1709160254 said: I ran the scripts against a 1912 to a new 1912 and everything except the icons came over. The icons are all Black Windows Icons. It would be great if the icons could import with over 250 applications...... It appears the error is, Set-BrokerApplication : Cannot bind argument to parameter 'InputObject' because it is null. At C:\sfbkp\import_apps.ps1:98 char:48 + Set-BrokerApplication -InputObject $application -IconUid ... + ~~~~~~~~~~~~ + CategoryInfo : InvalidData: (:) [Set-BrokerApplication], ParameterBindingValidationException + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Citrix.Broker.Admin.SDK.SetBrokerApplicationCommand Looking at the script I see line 98, c 48 Set-BrokerApplication -InputObject $application -IconUid $IconUid.Uid However in the xml file there is encoded icon data for every application. Any ideas? the script is trying to set the icon onto a null object meaning the $application variable is not being set correctly. if you change this line: $application = Get-BrokerApplication -BrowserName "$Results" and replace it with this line: $application = Get-BrokerApplication -PublishedName $app.PublishedName This then looks for the application with the same publishedname that you just created. I also had an issue with applications not in a folder failing, if you change the if statement from: if($app.AdminFolderName -ne $null) to: if($app.AdminFolderName.Length -gt 1) the script i used is attached, hopefully this is helpful. import_apps.ps1 1 Link to comment
1 Bogdan Shandurkov1709161004 Posted October 14, 2020 Share Posted October 14, 2020 On 4/20/2020 at 9:15 AM, Blair McLean1709161693 said: the script is trying to set the icon onto a null object meaning the $application variable is not being set correctly. if you change this line: $application = Get-BrokerApplication -BrowserName "$Results" and replace it with this line: $application = Get-BrokerApplication -PublishedName $app.PublishedName This then looks for the application with the same publishedname that you just created. I also had an issue with applications not in a folder failing, if you change the if statement from: if($app.AdminFolderName -ne $null) to: if($app.AdminFolderName.Length -gt 1) the script i used is attached, hopefully this is helpful. import_apps.ps1 6.4 kB · 81 downloads hi Blair, just adjusted the script using your recommendations - worked perfectly. BIG THANKS We were migrating applications between TEST & PROD farms running XA1912CU1 and got exactly the same problem - the export script runs just fine - the import script throws the same error below and all applications were missing icons : Set-BrokerApplication : Cannot bind argument to parameter 'InputObject' because it is null. After we adjusted the script with these 2 lines, everything runs perfectly: if you change this line: $application = Get-BrokerApplication -BrowserName "$Results" and replace it with this line: $application = Get-BrokerApplication -PublishedName $app.PublishedName This then looks for the application with the same publishedname that you just created. I also had an issue with applications not in a folder failing, if you change the if statement from: if($app.AdminFolderName -ne $null) to: if($app.AdminFolderName.Length -gt 1) I don't know what has changed from 7.15.x to 1912.x since the old script worked without issues. I am attaching both scripts that now work with XA1912.1 Many thanks again export_apps.ps1 import_apps_XA1912.ps1 1 Link to comment
0 matthew ingram Posted October 3, 2014 Share Posted October 3, 2014 First you Export your apps on the XDC: get-brokerapplication | export-clixml C:\apps.xml Copy this file to DC2 and run the following: $dg = Get-BrokerDesktopGroup "<desktop group name>" $apps = Import-Clixml C:\apps.xml foreach ($app in $apps) { New-BrokerApplication -ApplicationType HostedOnDesktop -BrowserName $app.Name -CommandLineExecutable -$app.CommandLineExecutable -Enabled $app.Enabled -Name $app.Name -UserFilterEnabled $app.UserFilterEnabled -DesktopGroup $dg $user = $app.AssociatedUserNames Add-BrokerUser -Name "$user" -Application $app.name } 2 Link to comment
0 Timothy Cochran Posted October 3, 2014 Author Share Posted October 3, 2014 Thanks for the quick reply. Ill give this a shot. I have 7.5 in production, and brought up a test for 7.6. It was going to be pain to re-add all the apps in the new controller and Google wasn't coming up with anything. Link to comment
0 Dmitry Parmit1709152850 Posted January 12, 2015 Share Posted January 12, 2015 Hey, this is great stuff. Export works great, but I have issue with import. Getting following error for each exported application. New-BrokerApplication : The name of the object must not exceed 64 characters in length and may not contain any ASCII control characters or any of the following: \/;:#.*?=<>|[]()"' Any ideas? Link to comment
0 Timothy Cochran Posted January 12, 2015 Author Share Posted January 12, 2015 Might be the $app.BrowerName length, maybe replace it with the $app.ApplicationName or $app.PublishedName. Do any of them get imported? I had this issue on some, but think I removed parameters until I found the one that was causing the issues. Link to comment
0 Dmitry Parmit1709152850 Posted January 13, 2015 Share Posted January 13, 2015 all of the application come back with some type of error. Looked closer and some giving different error. Will have to parse through each one... some complain about exceeding 64 characters as above. others produce: New-BrokerApplication : Cannot validate argument on parameter 'ClientFolder'. The argument is null I have about 40 applications that I am trying to migrate from one XA76 to another XA76. It would be great if I dont have to do it manually :) I know in older versions of XA, there were few very robust PoSH and VB scripts that could do this pragmatically. Yours was the first one I came across for XA 7.x. So thanks for sharing it with the rest of us. Link to comment
0 Dmitry Parmit1709152850 Posted January 27, 2015 Share Posted January 27, 2015 Found solution for ClientFolder error above. Apparently when adding new app using PoSH, this value can not be null. Even if this app was originally create inside GUI and has null value. Need to update it in GUI to have "\" character to indicate root or put it inside a folder. As long as there is some text. Now another problem :) Even though I can create and delete apps from GUI on the same DDC, running same script now gives me following towards very end of the script. New-BrokerApplication : Problem occurred contacting the database At D:\Software\pwshell\XenAppImport.ps1:17 char:5 + New-BrokerApplication -ApplicationType HostedOnDesktop -BrowserName $app.Bro ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [New-BrokerApplication], SdkOperationException + FullyQualifiedErrorId : Citrix.XDPowerShell.Broker.DataStoreException,Citrix.Broker.Admin.SDK.NewBrokerApplica tionCommand Link to comment
0 Kevin Jost Posted March 12, 2015 Share Posted March 12, 2015 I have tested both scripts. Export works well. When importing I also got the error described above (Problem occurred contacting the database). 5 of 33 exported applications, get recreated during the Import - rest throws the database error. Are there already new results? Why cmdlet gets stuck in a DataStoreExecption? Does anyone have a solution for this last error? Link to comment
0 Kevin Patrick Posted April 15, 2015 Share Posted April 15, 2015 Try this command in the import, it worked for me. Instead of using $app.name, try $app.ApplicationName. I did receive some red errors, but close Citrix Studio, open it, and the apps were now present. New-BrokerApplication -ApplicationType HostedOnDesktop -BrowserName $app.BrowserName -CommandLineExecutable $app.CommandLineExecutable -Description $app.Description -ClientFolder $app.ClientFolder -CommandLineArguments $app.CommandLineArguments -Enabled $app.Enabled -Name $app.Name -UserFilterEnabled $app.UserFilterEnabled -DesktopGroup $dg | Out-Null New-BrokerApplication -ApplicationType HostedOnDesktop -BrowserName $app.BrowserName -CommandLineExecutable $app.CommandLineExecutable -Description $app.Description -ClientFolder $app.ClientFolder -CommandLineArguments $app.CommandLineArguments -Enabled $app.Enabled -Name $app.applicationName -UserFilterEnabled $app.UserFilterEnabled -DesktopGroup $dg | Out-Null Link to comment
0 Christopher Barlow1709152983 Posted September 8, 2015 Share Posted September 8, 2015 Made some changes to the code, added icon recovery too This is a really helpful script thanks and is the first hit on Google for XenDesktop 7 published app import export. Would it be easy to add a filter to the export script so it only exports published apps that "contain $x" in the name, and add the filter as an optional parameter? Link to comment
0 Martin Fluck Posted November 10, 2015 Share Posted November 10, 2015 Hi Dmitry, Did you ever find a solution to this issue, I have a very similar situation where 8 out of a 100 or so applications will import fine but the rest throw the database access error. Checking over the XML I can see no difference between two applications: Word and Excel, one which does import and the other which doesn't.. Very frustrating Many thanks, Martin Found solution for ClientFolder error above. Apparently when adding new app using PoSH, this value can not be null. Even if this app was originally create inside GUI and has null value. Need to update it in GUI to have "\" character to indicate root or put it inside a folder. As long as there is some text. Now another problem :) Even though I can create and delete apps from GUI on the same DDC, running same script now gives me following towards very end of the script. New-BrokerApplication : Problem occurred contacting the database At D:\Software\pwshell\XenAppImport.ps1:17 char:5 + New-BrokerApplication -ApplicationType HostedOnDesktop -BrowserName $app.Bro ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: ( :) [New-BrokerApplication], SdkOperationException + FullyQualifiedErrorId : Citrix.XDPowerShell.Broker.DataStoreException,Citrix.Broker.Admin.SDK.NewBrokerApplica tionCommand Link to comment
0 Timothy Cochran Posted November 10, 2015 Author Share Posted November 10, 2015 Do you happen to have the error message your getting? are you getting New-BrokerApplication : Problem occurred contacting the database too? Could try adding try statements because whatever is happening is crashing the script Try { #Adding Application New-BrokerApplication -ApplicationType HostedOnDesktop -BrowserName $app.BrowserName -CommandLineExecutable $app.CommandLineExecutable -Description $app.Description -ClientFolder $app.ClientFolder -CommandLineArguments $app.CommandLineArguments -Enabled $app.Enabled -Name $app.Name -UserFilterEnabled $app.UserFilterEnabled -DesktopGroup $dg | Out-Null #Setting applications icon Set-BrokerApplication $app.name -IconUid $IconUid.Uidt } Catch { write-host $_.Exception.Message write-host $_.Exception.ItemName } Link to comment
0 Timothy Cochran Posted November 10, 2015 Author Share Posted November 10, 2015 While back I talked to Citrix Support about this, and they said this wasnt a supported idea. Not sure why not, this is very useful. Link to comment
0 Manbinder Pal Singh Posted November 24, 2015 Share Posted November 24, 2015 Have you tried using XA migration tool/scripts. You can run Export-XAFarm to export applications , servers , admin users, folders etc to a xml file with this simple to use migration tool. Later then you can use Import-XAFarm and use the exported xml to import on your new server.Atleast the exporting part to export you applications should work fine and if it doesnt then there could be a produt bug. Give it a shot and share the results. Link to comment
0 Manbinder Pal Singh Posted November 24, 2015 Share Posted November 24, 2015 You can download the scripts from https://www.citrix.com/downloads/xenapp/product-software/xenapp-76-enterprise-edition.html by expanding "Components updated or added since the initial release" and downloading XenApp Migration Script. Link to comment
0 Timothy Cochran Posted November 25, 2015 Author Share Posted November 25, 2015 Please read the forum post before posting. This forum post was not created for XenApp 6.5 to 7.x XenApp migrations. These migration scripts on here are from 7.X to another 7.X DDC site only. Those migration tools do not work for this type of applicaiton. You can download the scripts from https://www.citrix.com/downloads/xenapp/product-software/xenapp-76-enterprise-edition.html by expanding "Components updated or added since the initial release" and downloading XenApp Migration Script. Link to comment
0 Martin Fluck Posted December 1, 2015 Share Posted December 1, 2015 Hi Timothy, In the end it turned out to be the Description parameter that was throwing the errors in my environment. I excluded the Description as a property for my imported apps (don't really need it in my case) and the apps have all imported perfectly.. I'm now working on a version of the scripts above that include the Admin Folders as well as my environment has Dev and UAT in one XD Site and Prod in a separate site and I want all three to be mirrors of each other in terms of Admin Folders and Applications. We have a lot of app and a fairly extensive Admin Folder structure.. Got a few challenges, mainly around the fact you can define an Admin Folder Uid when you create it so the exported XML doesn't match up for Admin Folder for Apps. Once I have something that works I'll post it here. thanks for your help so far! Martin Link to comment
0 Christian Riederer Posted January 4, 2016 Share Posted January 4, 2016 Heya Guys and thanks for the glorious scripts. Export is working flawlessly, Import needed a revamp. Like everybody else i had some issues (Database Error and more). So i made a "verbose" Edition which i corrected slightly. The Database error hints to a parameter being NULL. The PS Script seemingly does not like that... My version imported everything just fine. PLEASE NOTE: if you still get errors it is most likely due to the wrong starting parameters (top of script - delivery group and file name) or due to NULL values i did not cover this is still far from perfcect (folder is more or less missing, as well as the differentiation of delivery groups (seemingly)) but it was enough to fit MY needs :) Add-PSSnapin Citrix* # Importing applications and associating icons with applications # Use: .\XenAppImport.ps1 "Delivery Group Name" #Getting Delivery Group from Arguments $dg = "YOURDELIVERYGROUPNAMEHERE" #Importing Application Data $apps = Import-Clixml C:\Apps.xml foreach ($app in $apps) { #Importing Icon $IconUid = New-BrokerIcon -EncodedIconData $app.EncodedIconData #Adding Application Write-Host $app.Name Try { if ($app.CommandLineArguments.Length -lt 2) {$app.CommandLineArguments = " "} #Adding Application write-host "Working on " $app.BrowserName write-host "Working on " $app.CommandLineExecutable write-host "Working on " $app.Description write-host "Working on " $app.CommandLineArguments write-host "Working on " $app.Enabled write-host "Working on " $app.applicationName write-host "Working on " $app.UserFilterEnabled New-BrokerApplication -BrowserName $app.BrowserName -CommandLineExecutable $app.CommandLineExecutable -Description $app.Description -ClientFolder "-" -CommandLineArguments $app.CommandLineArguments -Enabled $app.Enabled -Name $app.applicationName -UserFilterEnabled $app.UserFilterEnabled -DesktopGroup $dg | Out-Null #Setting applications icon Set-BrokerApplication $app.applicationname -IconUid $IconUid.Uid write-host "Working on Icon" $IconUid.Uid } Catch { write-host $_.Exception.Message write-host $_.Exception.ItemName write-host "Error on " $app.BrowserName write-host "Error on " $app.CommandLineExecutable write-host "Error on " $app.Description write-host "Error on " $app.CommandLineArguments write-host "Error on " $app.Enabled write-host "Error on " $app.applicationName write-host "Error on " $app.UserFilterEnabled } # Adding User Associations If($app.AssociatedUserNames -ne $null) { Try { $users = $app.AssociatedUserNames foreach($user in $users) { write-host "Working on User " $user $app.applicationname Add-BrokerUser -Name "$user" -Application $app.applicationname } } Catch { write-host $_.Exception.Message write-host $_.Exception.ItemName write-host "Error on User " $user $app.applicationname } } } Link to comment
0 Thiago Magalhães Mendes Guimarães Posted January 6, 2016 Share Posted January 6, 2016 Heya Guys and thanks for the glorious scripts. Export is working flawlessly, Import needed a revamp. Like everybody else i had some issues (Database Error and more). So i made a "verbose" Edition which i corrected slightly. The Database error hints to a parameter being NULL. The PS Script seemingly does not like that... My version imported everything just fine. PLEASE NOTE: if you still get errors it is most likely due to the wrong starting parameters (top of script - delivery group and file name) or due to NULL values i did not cover this is still far from perfcect (folder is more or less missing, as well as the differentiation of delivery groups (seemingly)) but it was enough to fit MY needs :) As Christian Riederer said: "Thanks for the glorious scripts. Export is working flawlessly Import needed a revamp." So I had to do a revamp on his import script to fit my customer needs. :D EXPORT SCRIPT First of, to make a separation for delivery groups you should export the xml only for the desired delivery group. To do so, you can do what i did: #Add citrix stuff Add-PSSnapin Citrix* #query for delivery group name and UID Get-BrokerDesktopGroup | select name,uid After that, get your desired delivery group uid and change your first line of the export script to: $apps = Get-BrokerApplication -DesktopGroupUid PUTYOURDELIVERYGROUPUIDHERE Execute the export script with this modification and you will get only the apps of this delivery group! Voilà! IMPORT SCRIPT I needed to keep ClientFolders, working directory and publishedname. So with the help of my customer and friend Gilmar Alcantara we made some modifications to Christian Riederer script. For the import script we included workingdirectory and publishedname parameters on the new-brokerapplication.. To solve the issue with Clientfolders missing we made a simple IF to test if its not null. If its not null, it will get the variable and when its null it will put a "\" to set as default path. If($app.ClientFolder -ne $null) { New-BrokerApplication -BrowserName $app.BrowserName -CommandLineExecutable $app.CommandLineExecutable -Description $app.Description -ClientFolder $app.ClientFolder -CommandLineArguments $app.CommandLineArguments -Enabled $app.Enabled -Name $app.Name -UserFilterEnabled $app.UserFilterEnabled -DesktopGroup $dg -WorkingDirectory $app.WorkingDirectory -PublishedName $app.PublishedName | Out-Null }else { New-BrokerApplication -BrowserName $app.BrowserName -CommandLineExecutable $app.CommandLineExecutable -Description $app.Description -ClientFolder "\" -CommandLineArguments $app.CommandLineArguments -Enabled $app.Enabled -Name $app.Name -UserFilterEnabled $app.UserFilterEnabled -DesktopGroup $dg -WorkingDirectory $app.WorkingDirectory -PublishedName $app.PublishedName | Out-Null } It worked like a charm for me! Tested on XenApp 7.5! I Guess it will serve as published applications backup! Any comments to improve it will be well accepted! Again, thank you all for providing those awesome scripts! Our import script version: # Adding Citrix stuff Add-PSSnapin Citrix* # Importing applications and associating icons with applications # Setting Delivery Group $dg = "YOURDELIVERYGROUPNAMEHERE" # Importing Application Data # Set the path to your .xml $apps = Import-Clixml C:\PATHTOXML\Apps.xml foreach ($app in $apps) { #Importing Icon $IconUid = New-BrokerIcon -EncodedIconData $app.EncodedIconData #Adding Application Write-Host $app.Name Try { if ($app.CommandLineArguments.Length -lt 2) {$app.CommandLineArguments = " "} #Adding Application write-host "BrowserName" $app.BrowserName write-host "ComdLineExe" $app.CommandLineExecutable write-host "Description" $app.Description write-host "ComdLineArg" $app.CommandLineArguments write-host "Enabled " $app.Enabled write-host "Name " $app.Name write-host "UserFiltEna" $app.UserFilterEnabled write-host "WorkingDire" $app.WorkingDirectory write-host "Published " $app.PublishedName If($app.ClientFolder -ne $null) { New-BrokerApplication -BrowserName $app.BrowserName -CommandLineExecutable $app.CommandLineExecutable -Description $app.Description -ClientFolder $app.ClientFolder -CommandLineArguments $app.CommandLineArguments -Enabled $app.Enabled -Name $app.Name -UserFilterEnabled $app.UserFilterEnabled -DesktopGroup $dg -WorkingDirectory $app.WorkingDirectory -PublishedName $app.PublishedName | Out-Null }else { New-BrokerApplication -BrowserName $app.BrowserName -CommandLineExecutable $app.CommandLineExecutable -Description $app.Description -ClientFolder "\" -CommandLineArguments $app.CommandLineArguments -Enabled $app.Enabled -Name $app.Name -UserFilterEnabled $app.UserFilterEnabled -DesktopGroup $dg -WorkingDirectory $app.WorkingDirectory -PublishedName $app.PublishedName | Out-Null } #Setting applications icon Set-BrokerApplication $app.Name -IconUid $IconUid.Uid write-host "Working on Icon" $IconUid.Uid } Catch { write-host $_.Exception.Message write-host $_.Exception.ItemName write-host "Error on " $app.BrowserName write-host "Error on " $app.CommandLineExecutable write-host "Error on " $app.Description write-host "Error on " $app.CommandLineArguments write-host "Error on " $app.Enabled write-host "Error on " $app.Name write-host "Error on " $app.UserFilterEnabled } # Adding User Associations If($app.AssociatedUserNames -ne $null) { Try { $users = $app.AssociatedUserNames foreach($user in $users) { write-host "Working on User " $user $app.Name Add-BrokerUser -Name "$user" -Application $app.Name } } Catch { write-host $_.Exception.Message write-host $_.Exception.ItemName write-host "Error on User " $user $app.Name } } } Link to comment
Question
Timothy Cochran
Is there currently a way of exporting and importing application settings in XenDesktop/XenApp 7.x? I know polices can be easily exported/imported via PowerShell, is there such a thing for Applications?
Link to comment
Top Posters For This Question
13
4
3
3
Popular Days
Oct 3
3
Oct 25
3
Jun 13
3
Nov 10
3
Top Posters For This Question
Timothy Cochran 13 posts
Kaspars Vilde 4 posts
Tim Carpenter 3 posts
Dmitry Parmit1709152850 3 posts
Popular Days
Oct 3 2014
3 posts
Oct 25 2018
3 posts
Jun 13 2019
3 posts
Nov 10 2015
3 posts
Posted Images
67 answers to this question
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now