We have a client where they still use a lot of published applications and we had a situation whereby we needed to update an attribute of dozens of applications . So I came up with the below script.
#####################
#
# Powershell Script
#
# Author - KumoInsight
# Email - contact@kumoinsight.co.uk
# Date - 10/07/2019
# Description - Script to Bulk Update Citrix 7.x Applications
#
# Version History
# 1.0 - 10/07/2019 Initial Version
#
#####################
#
# Requirements:
# - This will need to be done on a server with the Citrix Powershell Module installed, ideally once of the Delivery Controllers.
#
#####################
#
# Legal Disclaimer:
# This script is written by Patrick Carder is not supported under any support program or service.
# All scripts are provided AS IS without warranty of any kind.
# The author further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose.
# The entire risk arising out of the use or performance of the sample scripts and documentation remains with you.
# In no event shall its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if the author has been advised of the possibility of such damages.
#
#####################
# --- Loads Citrix Powershell Module --- #
asnp Citrix*
# --- Prompts and Generates Variables for Script --- #
$AppAttribute = Read-Host -Prompt 'Enter the Application Attribute you want to update'
$OldAttribute = Read-Host -Prompt 'Enter the Old Application Attribute Value you want to Replace'
$NewAttribute = Read-Host -Prompt 'Enter the New Application Attribute Value you want the Application to have'
$GetBrokerApp = @{$AppAttribute = $OldAttribute}
$SetBrokerApp = @{$AppAttribute = $NewAttribute}
# --- Lists and Prints all Applications using the Old Attribute declared above --- #
Write-Host " "
Write-Host "Generating list all the Applications with" $OldAttribute "in the " $AppAttribute "field"
Write-Host " "
$Apps = Get-Brokerapplication @GetBrokerApp
Write-Host "------------------------------------------"
Write-Host "------------------------------------------"
Write-Host "Printing list of Applications"
Write-Host "------------------------------------------"
Write-Host "------------------------------------------"
Get-Brokerapplication @GetBrokerApp | ft Name,ApplicationName,$AppAttribute
Get-Brokerapplication @SetBrokerApp | ft Name,ApplicationName,$AppAttribute
Write-Host "------------------------------------------"
Write-Host "------------------------------------------"
# --- Start of the Application Update Process --- #
Write-Host "Starting the Update Process"
Write-Host "------------------------------------------"
Write-Host "------------------------------------------"
Write-Host " "
ForEach ($App in $Apps) {Write-Host "Now updating -"$App.Name ;
Write-Host "Updating"$AppAttribute ;
Write-Host "Old Value:"$App.$AppAttribute;
Set-BrokerApplication -Name $App.Name @SetBrokerApp ;
Start-Sleep -s 2;
Write-Host "New Value:"$App.$AppAttribute ;
Write-Host "Application Updated";
Write-Host " ";
Write-Host "------------------------------------------";
Write-Host "------------------------------------------";Write-Host " "
}
# --- End of the Application Update Process --- #
# --- Lists and Prints all Applications using the Old Attribute declared above. This is check that all the applications have been update and none remain. --- #
Write-Host "Generating list all the Applications with" $OldAttribute "in the " $AppAttribute "field"
Write-Host " "
Write-Host "------------------------------------------"
Write-Host "Printing list of Applications"
Write-Host "------------------------------------------"
Write-Host "------------------------------------------"
Get-Brokerapplication @GetBrokerApp | ft Name,ApplicationName,$AppAttribute
Write-Host "------------------------------------------"
Write-Host "------------------------------------------"
# --- End of Script --- #
Write-Host "The Script has now completed"
Write-Host "------------------------------------------"
Write-Host "------------------------------------------"
0 Comments